I have just spent an entire day chasing down a problem with 'printing'
on HPUX and it turns out to be a 'OS' problem.  I strongly suspect
that this problem might be on other systems,  so I am issuing this
warning to the list.

Summary:  SO_LINGER does not work and close() discards untransmitted
     data.  (This is listed in HP's documents as an 'optimization'...:-)

How to reproduce the error:

Open a data link to a VERY slow receiver,  and make sure that the
data you send exceeds the sum of the receive buffer (on the remote host)
and the transmit buffer (on the sending host).  Note:  you need two hosts
to do this as send/receives to localhost do not appear to aggravate this
behaviour.

When you do a close,  the data pending in the 'transmit' buffer on the server
appears to be discarded.  The amount that is discarded is fairly random,
but some usually is.


Test code:

a)  get the LPRng distribution,  find common/monitor.c, and patch it as below.
    This will read a single character at a time.

b)  compile the tcpsend program attached below.

c)  start monitor on one host:
      monitor

d)  use tcpsend to send a file to the other host

    tcpsend remotehost 2001 <somefile

    Note: the tcpsend.c file is usually long enough.

e)  observe (hopefully!) that the entire file gets sent and
    received.

f)  Now edit the tcpsend.c file:

    }
    /* we shut down the connection */
    shutdown(sock,1);
    while( (n = read(sock,&buffer,sizeof(buffer))) > 0 );
    close(sock);
    return(0);


   Remove the shutdown and read lines:
    /* we shut down the connection */
#if 0
    shutdown(sock,1);
    while( (n = read(sock,&buffer,sizeof(buffer))) > 0 );
#endif
    close(sock);
    return(0);


g)  Recompile tcpsend and repeat the experiment.

    If you get the entire file,  then you can sign and dance your
    way down the halls in joy.

    If you do not get the entire file,  then you can now start the
    dreaded HP service support patch/fix/pray cycle.

Now while I have written this in a fairly lighthearted manner,
please note that there are a lot of people out there that may have
the same problem.

If you have been suffering from the mysterious 'unexpectedly terminate job'
syndrome,  then you may want to try this test as well.

Patrick Powell                 Astart Technologies,
[EMAIL PROTECTED]            9475 Chesapeake Drive, Suite D,
Network and System             San Diego, CA 92123
  Consulting                   858-874-6543 FAX 858-279-8424 
LPRng - Print Spooler (http://www.astart.com)

begin 664 tcpsend.c
M+RH*("H@=&-P<V5N9"!;+70@=&EM96]U=%T@:&]S="!P;W)T(%MF:6QE<UT*
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VXH<V]C
M:RPQ*3L*"7=H:6QE*"`H;B`](')E860H<V]C:RPF8G5F9F5R+'-I>F5O9BAB
M=69F97(I*2D@/B`P("D["@EC;&]S92AS;V-K*3L*"7)E='5R;B@P*3L*?0H*
M=F]I9"!D;U]S96YD*"!I;G0@<V]C:RP@:6YT(&9D+"!C:&%R("IN86UE("D*
M>PH):6YT(&-N="P@;BP@:3L*"7=H:6QE*"`H;B`](')E860H9F0L8G5F9F5R
M+'-I>F5O9BAB=69F97(I*2D@/B`P("E["@D)9F]R*"!C;G0@/2!I(#T@,#L@
M8VYT(#X](#`@)B8@:2`\(&X[(&D@*ST@8VYT("E["@D)"6-N="`]('=R:71E
M*'-O8VLL8G5F9F5R*VDL;BUI*3L*"0E]"@D):68H(&-N="`\(#`@*7L*"0D)
M9G!R:6YT9BAS=&1E<G(L("(E<SH@8V%N;F]T('=R:71E('1O(')E;6]T92!H
M;W-T("T@)7-<;B(L"@D)"0E0<F]G+"!S=')E<G)O<BAE<G)N;RD@*3L*"0D)
M97AI="@Q*3L*"0E]"@E]"@EI9B@@;B`\(#`@*7L*"0EF<')I;G1F*'-T9&5R
M<BP@(B5S.B!C86YN;W0@<F5A9"!F<F]M("<E<R<@+2`E<UQN(BP*"0D)4')O
L9RP@;F%M92P@<W1R97)R;W(H97)R;F\I("D["@D)97AI="@Q*3L*"7T*?0IO
`
end

*** /tmp/monitor.c      Sat Oct 14 12:55:00 2000
--- common/monitor.c    Wed Oct 11 10:07:28 2000
***************
*** 239,245 ****
                                        if( i >= max_port ) max_port = i+1;
                                        FD_SET(i, &readfds);
                                } else {
!                                       c = read( i, buffer, 1 );
                                        if( c == 0 ){
                                                /* closed connection */
                                                FPRINTF(STDOUT, "closed connection 
%d\n", i );
--- 239,245 ----
                                        if( i >= max_port ) max_port = i+1;
                                        FD_SET(i, &readfds);
                                } else {
!                                       c = read( i, buffer, sizeof(buffer)-1 );
                                        if( c == 0 ){
                                                /* closed connection */
                                                FPRINTF(STDOUT, "closed connection 
%d\n", i );
***************
*** 257,263 ****
                                                        memmove(in->buffer,s, 
strlen(s)+1 );
                                                        in->len = strlen(in->buffer);
                                                }
-                                               usleep(10000); /* wait 10 milliseconds 
*/
                                        } else {
                                                FPRINTF( STDERR, "read error - %s\n",
                                                        Errormsg(errno) );
--- 257,262 ----

-----------------------------------------------------------------------------
YOU MUST BE A LIST MEMBER IN ORDER TO POST TO THE LPRNG MAILING LIST
The address you post from MUST be your subscription address

Reply via email to