18.7.11

SAP Note 26641 - ISHCM locking transceiver files

Symptom:

Miscellaneous.The transceiver programs often remain hanging and can then no longer be stopped anymore by means of "kill -9".
On Windows NT, you may find that messages arrive incompletely in the NTISH.dat file (this in turn causes the additional error that SS_STAT.dat is not locked).
It is also advantageous for programming partner connections to the R/3 communication module if you are acquainted with the locking mechanism (see below).
Additional key words

File locks, locking, ISHCM, transceivers, put_tab, PUT_TAB, consulting
Cause and prerequisites

Diverse.Problems often occur in connection with the file systems mounted.Read the related notes for more information.
On Windows NT, the special feature still exists that a file lock without a size specification (which is actually common) only refers to the file in available length. That means appending is possible despite the lock.
Solution

Difficult.In order to determine the cause of the error it can be helpful to know the locking mechanism of the transceiver programs.

When transferring data out from within the R/3 System, SS_STAT.dat is used as the central lock object (see documentation "SAP R/3 communications module"). That is important. It is not the data file which is the lock object here but SS_STAT.dat. Therefore, the partner program need (only) lock SS_STAT.dat in the case of this communication direction. If only NTISH.dat is locked, it can create a diverse range of error symptoms.

When receiving data into the R/3 System, the corresponding files are always locked directly (not SS_STAT.dat).

Clarify C source code statements here which the locking mechanism creates when transferring data out of R/3:

1. .tmp (is called differently as of transceiver 1.42) and fill:
if (fp == NULL) {
if ((fp = fopen{NTXXXTEMP,"w+"))==NULL)
exit(1);
}
fputs(.....

2. lock SS_STAT.dat:
if ((sfd=LockFile(SS_STAT))==-1) goto ssstatfalse;

3. replace .dat by .tmp-Rename (or append in the append mode):
if (rename(NTXXXTEMP, NTXXXFILE)) goto renamefalse;

The routine used under 2) should look as follows:
int LockFile(fname)
char *fname;
{
int try;
int sfd;
time_t t;

try = 0;
while (1) {
#ifndef OS2
sfd = open(fname, O_RDWR|O_CREAT, 0666);
if (sfd==-1) return -1;
lck.l_type=F_WRLCK;
lck.l_whence = 0;
lck.l_start = 01;
lck.l_len = 01;
if (fcntl(sfd,F_SETLK, &lck) < 0) {
if (++try < MAXTRY) { close(sfd); sleep(2); }
else return -1;
} else return sfd;
#else
sfd = sopen(fname, O_RDWR|O_CREAT, SH_DENYRW, S_IREAD|S_IWRITE);
if (sfd==-1) {
if (++try < MAXTRY) {
t = time(01);
while (time(01)-t < 3) ;
} else return -1;
} else return sfd;
#endif
}
}

No comments:

Post a Comment