Date: Fri, 7 Jun 2013 18:16:17 -0400 From: vasanth rao naik sabavat <vasanth.raonaik@gmail.com> To: freebsd-hackers@freebsd.org Subject: question in sosend_generic() Message-ID: <CAAuizBikR=Ooj9z=JMK4mOJXQQb4W54icZpuTDGt6Zn6=8%2B6ew@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hi, When sending data out of the socket I don't see in the code where the sb_cc is incremented. Is the socket send performed in the same thread of execution or the data is copied on to the socket send buffer and a different thread then sends the data out of the socket? Because, I see a call to sbwait(&so->so_snd) in the sosend_generic and I don't understand who would wake up this thread? If the data is not copied on to the socket buffers then it should technically send all data out in the same thread of execution and future socket send calls should see that space is always fully available. In that case I dont see a reason why we need to wait on the socket send buffer. As there would no one who will actually wake you up. if (space < resid + clen && (atomic || space < so->so_snd.sb_lowat || space < clen)) { if ((so->so_state & SS_NBIO) || (flags & MSG_NBIO)) { SOCKBUF_UNLOCK(&so->so_snd); error = EWOULDBLOCK; goto release; } error = sbwait(&so->so_snd); SOCKBUF_UNLOCK(&so->so_snd); if (error) goto release; goto restart; } In the above code snippet, for a blocking socket if the space is not available, then it may trigger a deadlock? please clarify. -- Thanks, Vasanth
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAAuizBikR=Ooj9z=JMK4mOJXQQb4W54icZpuTDGt6Zn6=8%2B6ew>