From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 7 22:16:20 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 41DEF29D for ; Fri, 7 Jun 2013 22:16:20 +0000 (UTC) (envelope-from vasanth.raonaik@gmail.com) Received: from mail-la0-x235.google.com (mail-la0-x235.google.com [IPv6:2a00:1450:4010:c03::235]) by mx1.freebsd.org (Postfix) with ESMTP id C3CE117E2 for ; Fri, 7 Jun 2013 22:16:19 +0000 (UTC) Received: by mail-la0-f53.google.com with SMTP id fs12so2672645lab.40 for ; Fri, 07 Jun 2013 15:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=SndYymwLZ1cY/jx3zKfHVm1cKufVlbWaI3NiilarLo0=; b=Mjeip7+MJJpsiM4qRaF0ZrLJuR12xV87FBZi164xi7cC63u8iCCf7N6yEnq+d3GtIz FqyEdojr4cNsAvq5aXaCBeo0O5a4xfmmLC0ejvpNe241/mJhHAkAE3FIl8Tt84XGxMpd onB7vhgtkMU0QXc0UVBtIBvReKm98RHUb7PvfFuOuuY9XybtPR/66hoc4V6+14Ar9jYU GIVGNNua7ZPNn01vDHu35pdLbnukWybWjW0lZrRZ91KJ4qH3kLycjy8mr6fxCrLIee5I QewONoZb/xrUCcEKg+v7N2bSM0BUmY8c7wcsysH86k5Kb3rlFK1Nw+ByQdxMjRx+D1Nv fcew== MIME-Version: 1.0 X-Received: by 10.152.2.233 with SMTP id 9mr321894lax.34.1370643377341; Fri, 07 Jun 2013 15:16:17 -0700 (PDT) Received: by 10.112.143.39 with HTTP; Fri, 7 Jun 2013 15:16:17 -0700 (PDT) Date: Fri, 7 Jun 2013 18:16:17 -0400 Message-ID: Subject: question in sosend_generic() From: vasanth rao naik sabavat To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jun 2013 22:16:20 -0000 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