lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] TCP Client system fault


From: Vinicius Bernardi
Subject: [lwip-devel] TCP Client system fault
Date: Mon, 30 Apr 2012 01:20:06 -0300

Hi Kieran,

I didn't remove code from do_write

I remove this code below(<<<<<<<<)

As this code is dependent of the callback function to be registered.
And as I said, if there is 1 write bigger then the buffer happens, and the 
second write happens, the status will be NETCONN_WRITE, I can do the second 
write as the first part of package it's already send, then the ACK from network 
is received, and the function sent_tcp is called, and there is no reason for 
this function to call do_writemore in my opnion, but it was calling, and 
breaking the semaphore logic.
Then when I call the function netconn_write again, the semaphore it's auto 
released so there is no waiting, the stack is been used, and tcpip_thread is 
receiving garbage inside of MBOX. That was my causing of faults.

Best regards,
Vinicius


/**
 * Sent callback function for TCP netconns.
 * Signals the conn->sem and calls API_EVENT.
 * netconn_write waits for conn->sem if send buffer is low.
 *
 * @see tcp.h (struct tcp_pcb.sent) for parameters and return value
 */
static err_t
sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len)
{
  struct netconn *conn = (struct netconn *)arg;

  LWIP_UNUSED_ARG(pcb);
  LWIP_ASSERT("conn != NULL", (conn != NULL));

//  if (conn->state == NETCONN_WRITE) { <<<<<<<<<<<<<<<<<<<<<<<<<<
//    do_writemore(conn);
//  } else 
  if (conn->state == NETCONN_CLOSE) {
    do_close_internal(conn);
  }

  if (conn) {
    /* If the queued byte- or pbuf-count drops below the configured low-water 
limit,
       let select mark this pcb as writable again. */
    if ((conn->pcb.tcp != NULL) && (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT) &&
      (tcp_sndqueuelen(conn->pcb.tcp) < TCP_SNDQUEUELOWAT)) {
      conn->flags &= ~NETCONN_FLAG_CHECK_WRITESPACE;
      API_EVENT(conn, NETCONN_EVT_SENDPLUS, len);
    }
  }
  
  return ERR_OK;
}



> 1 - I had writen some data using netconn_write 
> Then I had received a semaphore post saying that the TCPIP thread already 
> process that message
> 
> Then PPP thread receive a package (IP buffer) and process it, but during the 
> process of that package the code decide to call do_write method again ( it's 
> related to SEND EVENT about the message confirmed - previous message maybe ) 
> 
> With this new POST again at semaphore, my next write to netconn_write will be 
> out of sync, because I will not wait again, as my semaphore it's already 1 , 
> and it will be released imediatly.
> 
> In my solution for now it's to remove the do_writemore inside of API to send 
> signal, as there is no sense to be there.
> 
> I would like some comments if it's possible.

It sounds like something is seriously wrong here, but I'm not sure what.  I do 
not think that your solution of removing code from do_writemore is correct.  It 
sounds like your problems happen when you have two writes going on at the same 
time.

> Another important question :
> 
> I'm trying to write huge packages, 1600 bytes for example, how the 
> netconn_write should handle it? Right now, there is a output of 1400 bytes 
> and I receive ACK that everything it's ok, and it's not ok, there is a part 
> of package missing.

I would expect a large write to get split if necessary into smaller chunks so 
that they will fit into packets.  It sounds like this is happening, at least in 
part, because the 1400 bytes get sent.  What isn't clear is if the next 200 
bytes also get sent later.

Kieran


reply via email to

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