> 
> static ssize_t
> Recv(Ns_Sock *sock, struct iovec *bufs, int nbufs, Ns_Time
> *timeoutPtr, int flags)
> {
>     static const char request[] = "GET /whateva HTTP/1.0\r\n\r\n";
>     size_t requestLen = sizeof(request);
>     socklen_t sockLen = sizeof(struct sockaddr_in);
> 
>     memcpy(bufs->iov_base, request, requestLen);
> 
>     return recvfrom(sock->sock,
>                     bufs->iov_base + requestLen,
>                     bufs->iov_len - requestLen,
>                     0, (struct sockaddr*) &sock->sa, &size);
> }
> 
> (checking for buffer lengths skipped here)
> 
> 
> The advantage of doing it this way is that everything is much simpler
> from the driver threads point of view. It doesn't need to know
> anything special about non-standard protocols, and there isn't
> anything in the driver callback api that isn't also useful to the HTTP
> server.


Arguable this is not very clear and simple, driver will have to hack 
buffers and every request should pretend to be HTTP just so driver 
thread would think that it serves only HTTP requests.

If we have special codes and already have 3, does another one breaks 
anythings if only one code makes overall process simpler not only in 
driver thread but for drivers itself?

The only reason of new code because SOCK_READY does queue socket 
immediately but because request structure is not set, NsGetRequest will 
call SockRead/SockParse. Basically ACCEP_QEUEU code is the same as 
ACCEPT_DATA but it skips hacking HTTP request buffer and let the conn 
thread perform processing where ACCEPT_DATA assumes HTTP request and 
assumes HTTP flow to be performed.



> Also, this can't work:
> 
> nsd/driver.c:1515
> 
> status = DriverAccept(sockPtr);
> 
> if (status == NS_DRIVER_ACCEPT_ERROR) {
>     status = SOCK_ERROR;
>     ...
> 
> } else {
>     status = SOCK_MORE;
>     ...
> 
>     if (status == NS_DRIVER_ACCEPT_DATA) {
>         ...
>     } else if (status == NS_DRIVER_ACCEPT_QUEUE) {
>         ...
>     }
> }

Oops, my bad



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to