[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] http_sent cb shows 1 byte trailer [RAW]

From: Chris Strahm
Subject: Re: [lwip-users] http_sent cb shows 1 byte trailer [RAW]
Date: Tue, 11 Aug 2009 10:12:27 -0700

> What confused me all the time is that *any* callback gets called *after*
> the call to close_conn(), as this resets the callback-arg as well as the
> recv- and sent-callbacks of the pcb. However, maybe your close_conn()
> doesn't do that. If so, I'd wonder why the callback functions get called
> after they were reset. Maybe it's only a misunderstanding.

This is the code I have been running for my close_conn()

static void close_conn(struct tcp_pcb *pcb, struct http_state *hs) {
   err_t err;
 if(hs) DEBUG_PRINT("close_conn: pcb=0x%08X hs=0x%08X SendCnt=%d\n", pcb,
hs, hs->SendCnt);
  else DEBUG_PRINT("close_conn: pcb=0x%08X hs=0x%08X\n ", pcb, hs);
   tcp_arg(pcb, NULL);
   tcp_sent(pcb, NULL);
   tcp_recv(pcb, NULL);
   if(hs) mem_free(hs);
   err = tcp_close(pcb);
   if(err != ERR_OK)
  printf("Error %s closing pcb=0x%08X\n", lwip_strerr(err), pcb);

As you can see it clears the tcp_sent cb.  Yes I agree with you it seems
outright impossible that lwip can still be calling the cb after this has
been cleared, but that's exactly what it does.

Now in the BYU code, they do something interesting.  They do NOT clear the
cb's for sent or rcve in close_conn() at all.  I've run that setup too, and
the output is shown below.  Note that there are 2 additional calls made at
the end.  http_recv() gets triggered again and so does close_conn().  Here
we have another case of double close_conn().

The wireshark trace is clean with this setup as well.  I don't know why the
guys at BYU removed those 2 NULLs, but apparently they have them commented
out for a reason.  Personally I don't see much effective difference either
way, the end results are nearly identical.  But perhaps they did other tests
and found a problem this solved.

CON>End of File /logostop.gif
CON>close_conn: pcb=0x4000791C hs=0x40004E64 SendCnt=2437
CON>http_sent: pcb=0x4000791C hs=0x00000000 len=2437
CON>http_sent: pcb=0x4000791C hs=0x00000000 len=1
CON>http_recv: pcb=0x4000791C pbuf=0x00000000 err=Ok.
CON>close_conn: pcb=0x4000791C hs=0x00000000


reply via email to

[Prev in Thread] Current Thread [Next in Thread]