Hi



I have a problem where I am writing to a save file after receiving the
records from a remote system. Every so often I am getting a failure where
the save file is written. A message CPF5175 is sent after a write to the
file, but the fdbk area is still showing the record was correctly added. I
think this is to do with the caching of the writes until 32K has been
written? It appears IBM checks the CRC of the last 32K as it adds it to the
file, when this CRC is incorrect it will fail with the CPF 5175 error.



Here is a bit of the code to show what is happening, I have even added a
check every 60 records to make sure the write has been performed correctly!



for(i = 0,j = 0; i < Request.Records; i++,j++) {

rc = recv(accept_sd, Savf_Buf,528,0);

if(rc < 0) {

sprintf(msg_dta," recv() failed %s",strerror(errno));

snd_msg("GEN0001",msg_dta,strlen(msg_dta));

close(accept_sd);

return -1;

}

if(rc == 528) {

fdbk = _Rwrite(fp,Savf_Buf,528); <<< this is where the CPF5175 message
says it originates.

if(fdbk->num_bytes != 528) {

sprintf(msg_dta,"Error on write %s",strerror(errno));

close(accept_sd);

return -1;

}

}

else {

offset = 0;

total_bytes += rc;

do {

offset += rc;

rc = recv(accept_sd,&Savf_Buf[offset],528 - offset,0);

if(rc < 0) {

sprintf(msg_dta," recv() failed %s",strerror(errno));

snd_msg("GEN0001",msg_dta,strlen(msg_dta));

close(accept_sd);

return -1;

}

total_bytes += rc;

}while(total_bytes < 528);

fdbk = _Rwrite(fp,Savf_Buf,528);

if(fdbk->num_bytes != 528) {

sprintf(msg_dta,"Error on write %s",strerror(errno));

close(accept_sd);

return -1;

}

}

if(j == 60) {

rc = send(accept_sd,"OK",2,0);

j = 0;

}

}

_Rclose(fp);



This is the code that sends the request.



for(i = 0, j = 0; i < details->Records; i++,j++) {

fdbk = _Rreadn(fp,Cpy_Buf,528,__DFT);

if(fdbk->num_bytes == 528) {

len = send(sockfd, Cpy_Buf,528, 0);

total_bytes += len;

if(len != 528) {

sprintf(msg_dta," send() Cpy_Buf failed %s bytes sent %l",

strerror(errno),total_bytes);

snd_msg("GEN0001",msg_dta,strlen(msg_dta));

close(sockfd);

Add_to_Failed(RepDta,msg_dta);

QUSDLTUS(Sav_Spc_Name,

&Error_Code);

if(Error_Code.EC.Bytes_Available > 0) {

snd_error_msg(Error_Code);

}

return -1;

}

}

else {

sprintf(msg_dta,"Failed to read record - bytes read %d",

fdbk->num_bytes);

snd_msg("GEN0001",msg_dta,strlen(msg_dta));

_Rclose(fp);

close(sockfd);

Add_to_Failed(RepDta,msg_dta);

QUSDLTUS(Sav_Spc_Name,

&Error_Code);

if(Error_Code.EC.Bytes_Available > 0) {

snd_error_msg(Error_Code);

}

return -1;

}

/* check at 32k limit for processing */

if(j == 60) {

len = recv(sockfd, recv_buf, 2, 0);

if(memcmp(recv_buf,"OK",2) == 0) {

j = 0;

}

else {

/* error in record count! */

sprintf(msg_dta," recv() count check failed");

snd_msg("GEN0001",msg_dta,strlen(msg_dta));

close(sockfd);

Add_to_Failed(RepDta,msg_dta);

QUSDLTUS(Sav_Spc_Name,

&Error_Code);

if(Error_Code.EC.Bytes_Available > 0) {

snd_error_msg(Error_Code);

}

return -1;

}

}



The error is always shown as coming from the line marked, but the program is
continuing because fdbk->num_bytes is set to 528. The problem is the program
is ending but leaving the save file open so subsequent requests to this
function cannot access the save file!!! I THINK the data is corrupted in the
transfer and IBM is not picking it up? I have seen in other articles that
IBM I is very bad on TCP/IP error capture???



I would like to capture the CPF5175 error somehow and clean up so other
requests will not fail. I can log a retry on the source for the object so it
will be recoverable. What is the best way to do this? Should I just add a
signal capture and respond to it using

#pragma exception handler around the _Rwrite? Why isn?t this error reported
back through the fdbk structure? I added the 60 record check and did a debug
to see what records were causing the problem but it was always different.
What I can say is this only occurs when the comms is heavily loaded?



Hope someone has some ideas? I will keep looking for Comms PTF?s as my V6R1
system does not exhibit the same behavior just the customers system running
V5R4..



Chris Hird





Chris Hird

Director

Shield Advanced Solutions Ltd

http://www.shield.on.ca

1(519) 940-1192

____________________________________________________________________________
_______

Please consider the environment before printing this email.



This message, including any attached documents, is intended for the
addressees only. It may contain information that is confidential, privileged
and/or exempt from disclosure. No rights to privilege or confidentiality
have been waived. Any unauthorized use or disclosure is prohibited. If you
have received this message in error, please reply to the sender by e-mail
and delete or destroy all copies of this message.

______________________________________________________

Avant d'imprimer ce courriel, pensez à l'environnement.



Ce message, incluant tous les documents joints, est à l'intention des
destinataires visés seulement. Il peut contenir des renseignements
confidentiels, protégés et/ou ne pouvant pas être divulgués. Aucune
renonciation n'est faite quant à sa nature confidentielle et privilégiée.
Par conséquent, toute diffusion ou utilisation non autorisée est strictement
interdite. Si vous avez reçu ce message par erreur, veuillez en aviser
immédiatement l'expéditeur par retour de courriel et en détruire toutes les
copies existantes.




This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].