I think it was working perfectly fine, new buffer size is set on 
accepted socket, new one, not the one we listened.


I used to play with these options for one of the modules i wrote and at 
least on Linux it was working fine.

Also i found this about this option:
You can increase a stream socket's buffer size at any time, but decrease 
it only prior to establishing a connection. The maximum buffer size for 
stream sockets is 262144 bytes.



Zoran Vasiljevic wrote:
> Update of /cvsroot/naviserver/naviserver/nsd
> In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8949/nsd
> 
> Modified Files:
>       driver.c 
> Log Message:
> nsd/driver.c: Socket send/recv buffer setup moved to NsStartDrivers()
> and commented as real NO-OP, as too late in the startup sequence.
> TCP honours the buffer-size setup prior to listen() or connect() only.
> Without significant API plumbing, the per-driver values for send and
> receive buffers are just useless.
> 
> 
> Index: driver.c
> ===================================================================
> RCS file: /cvsroot/naviserver/naviserver/nsd/driver.c,v
> retrieving revision 1.97
> retrieving revision 1.98
> diff -C2 -d -r1.97 -r1.98
> *** driver.c  18 Dec 2007 18:21:39 -0000      1.97
> --- driver.c  26 Apr 2008 19:47:52 -0000      1.98
> ***************
> *** 551,627 ****
>   NsStartDrivers(void)
>   {
> !     Driver *drvPtr;
> !     SpoolerQueue *queuePtr;
>   
>       /*
> !      * Listen on all drivers.
>        */
>   
>       drvPtr = firstDrvPtr;
>   
>       while (drvPtr != NULL) {
> -         if (drvPtr->opts & NS_DRIVER_UNIX) {
> -             drvPtr->sock = Ns_SockListenUnix(drvPtr->bindaddr,
> -                                              drvPtr->opts & NS_DRIVER_UDP ? 
> 0 :
> -                                                             
> drvPtr->backlog, 0);
>   
> !         } else if (drvPtr->opts & NS_DRIVER_UDP) {
> !             drvPtr->sock = Ns_SockListenUdp(drvPtr->bindaddr,
> !                                             drvPtr->port);
>   
>           } else {
> !             drvPtr->sock = Ns_SockListenEx(drvPtr->bindaddr,
> !                                            drvPtr->port, drvPtr->backlog);
>           }
>           if (drvPtr->sock == INVALID_SOCKET) {
> !             Ns_Log(Error, "%s: failed to listen on %s:%d: %s",
> !                    drvPtr->name, drvPtr->address, drvPtr->port,
> !                    ns_sockstrerror(ns_sockerrno));
>           } else {
>   
>               Ns_SockSetNonBlocking(drvPtr->sock);
> -             Ns_Log(Notice, "%s: listening on %s:%d",
> -                    drvPtr->name, drvPtr->address, drvPtr->port);
>   
>               /*
> !              * Create the spooler thread(s).
>                */
>   
> !             queuePtr = drvPtr->spooler.firstPtr;
> !             while (queuePtr) {
> !                 if (ns_sockpair(queuePtr->pipe) != 0) {
> !                     Ns_Fatal("driver: ns_sockpair() failed: %s",
> !                              ns_sockstrerror(ns_sockerrno));
> !                 }
> !                 Ns_ThreadCreate(SpoolerThread, queuePtr, 0,
> !                                 &queuePtr->thread);
> !                 queuePtr = queuePtr->nextPtr;
>               }
>   
>               /*
> !              * Create the writer thread(s)
>                */
>   
> !             queuePtr = drvPtr->writer.firstPtr;
> !             while (queuePtr) {
> !                 if (ns_sockpair(queuePtr->pipe) != 0) {
> !                     Ns_Fatal("driver: ns_sockpair() failed: %s",
> !                              ns_sockstrerror(ns_sockerrno));
>                   }
> -                 Ns_ThreadCreate(WriterThread, queuePtr, 0,
> -                                 &queuePtr->thread);
> -                 queuePtr = queuePtr->nextPtr;
>               }
>           }
>           drvPtr = drvPtr->nextPtr;
>       }
>   
>       /*
> !      * Create the driver thread.
>        */
>   
> !     if (firstDrvPtr != NULL) {
> !         if (ns_sockpair(drvPipe) != 0) {
> !             Ns_Fatal("driver: ns_sockpair() failed: %s",
>                        ns_sockstrerror(ns_sockerrno));
>           }
> --- 551,648 ----
>   NsStartDrivers(void)
>   {
> !     int          i, bl, ncommd;
> !     Driver       *drvPtr;
> !     SpoolerQueue *qPtr;
> ! 
> !     struct {
> !         Ns_ThreadProc *tproc;
> !         SpoolerQueue  *queue;
> !     } thr[] = {{SpoolerThread, NULL}, {WriterThread,  NULL}};
>   
>       /*
> !      * Listen on all communication drivers.
>        */
>   
>       drvPtr = firstDrvPtr;
> +     ncommd = 0;
>   
>       while (drvPtr != NULL) {
>   
> !         bl = (drvPtr->opts & NS_DRIVER_UDP) ? 0 : drvPtr->backlog;
>   
> +         if (drvPtr->opts & NS_DRIVER_UNIX) {
> +             drvPtr->sock = Ns_SockListenUnix(drvPtr->bindaddr, bl, 0);
> +         } else if (drvPtr->opts & NS_DRIVER_UDP) {
> +             drvPtr->sock = Ns_SockListenUdp(drvPtr->bindaddr, drvPtr->port);
>           } else {
> !             drvPtr->sock = Ns_SockListenEx(drvPtr->bindaddr, drvPtr->port, 
> bl);
>           }
>           if (drvPtr->sock == INVALID_SOCKET) {
> !             Ns_Log(Error, "%s: failed to listen on %s:%d: %s", drvPtr->name,
> !                    drvPtr->address, drvPtr->port, 
> ns_sockstrerror(ns_sockerrno));
>           } else {
>   
>               Ns_SockSetNonBlocking(drvPtr->sock);
>   
>               /*
> !              * Set the send/recv socket bufsizes if required.
> !              * Note: it's too late to set them here, as TCP manual says:
> !              *
> !              *     On individual connections, the socket buffer size 
> !              *     must be set prior to the listen() or connect() calls
> !              *     in order to have it take effect.
> !              *
> !              * So now what? The binder process already did all of that for
> !              * us early on startup! So whatever we do here below does not
> !              * really matter.  We must move this early in the binding 
> process
> !              * somehow, but that requires significant API plumbing... Phew.
> !              *
>                */
>   
> !             if (drvPtr->sndbuf > 0) {
> !                 setsockopt(drvPtr->sock, SOL_SOCKET, SO_SNDBUF,
> !                            (char *) &drvPtr->sndbuf, 
> sizeof(drvPtr->sndbuf));
> !             }
> !             if (drvPtr->rcvbuf > 0) {
> !                 setsockopt(drvPtr->sock, SOL_SOCKET, SO_RCVBUF,
> !                            (char *) &drvPtr->rcvbuf, 
> sizeof(drvPtr->rcvbuf));
>               }
>   
> +             Ns_Log(Notice, "%s: listening on %s:%d", drvPtr->name,
> +                    drvPtr->address, drvPtr->port);
> + 
> +             ncommd++; /* Yet another successfuly started comm driver */
> + 
>               /*
> !              * Create the spooler/writer thread(s).
>                */
>   
> !             thr[0].queue = drvPtr->spooler.firstPtr;
> !             thr[1].queue = drvPtr->writer.firstPtr;
> ! 
> !             for (i = 0; i < 2; i++) {
> !                 qPtr = thr[i].queue;
> !                 while (qPtr != NULL) {
> !                     if (ns_sockpair(qPtr->pipe)) {
> !                         Ns_Fatal("ns_sockpair() failed: %s",
> !                                  ns_sockstrerror(ns_sockerrno));
> !                     }
> !                     Ns_ThreadCreate(thr[i].tproc, qPtr, 0, &qPtr->thread);
> !                     qPtr = qPtr->nextPtr;
>                   }
>               }
>           }
> + 
>           drvPtr = drvPtr->nextPtr;
>       }
>   
>       /*
> !      * Create the driver thread itself if we managed to
> !      * get at least one of the communication drivers.
>        */
>   
> !     if (ncommd > 0) {
> !         if (ns_sockpair(drvPipe)) {
> !             Ns_Fatal("ns_sockpair() failed: %s",
>                        ns_sockstrerror(ns_sockerrno));
>           }
> ***************
> *** 1678,1694 ****
>       Ns_SockSetNonBlocking(sockPtr->sock);
>   
> -     /*
> -      * Set the send/recv socket bufsizes if required.
> -      */
> - 
> -     if (drvPtr->sndbuf > 0) {
> -         setsockopt(sockPtr->sock, SOL_SOCKET, SO_SNDBUF,
> -                    (char *) &drvPtr->sndbuf, sizeof(drvPtr->sndbuf));
> -     }
> -     if (drvPtr->rcvbuf > 0) {
> -         setsockopt(sockPtr->sock, SOL_SOCKET, SO_RCVBUF,
> -                    (char *) &drvPtr->rcvbuf, sizeof(drvPtr->rcvbuf));
> -     }
> - 
>       drvPtr->queuesize++;
>   
> --- 1699,1702 ----
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
> Don't miss this year's exciting event. There's still time to save $100. 
> Use priority code J8TL2D2. 
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> naviserver-commits mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/naviserver-commits
> 

-- 
Vlad Seryakov
[EMAIL PROTECTED]
http://www.crystalballinc.com/vlad/

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to