Skip to content

Commit

Permalink
Added read and write filters, fixed bugs with pre-queue filters and
Browse files Browse the repository at this point in the history
que-wait callbacks, added ns_tls, ns_cls, and ns_quewait commands.
  • Loading branch information
jgdavidson committed Dec 8, 2009
1 parent 758b134 commit 22c0ef3
Show file tree
Hide file tree
Showing 9 changed files with 547 additions and 87 deletions.
4 changes: 2 additions & 2 deletions nsd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# version of this file under either the License or the GPL.
#
#
# $Header: /Users/dossy/Desktop/cvs/aolserver/nsd/Makefile,v 1.52 2006/06/27 16:35:55 jgdavidson Exp $
# $Header: /Users/dossy/Desktop/cvs/aolserver/nsd/Makefile,v 1.53 2009/12/08 04:12:19 jgdavidson Exp $
#

INSTALL = install-init
Expand All @@ -47,7 +47,7 @@ OBJS = adpcmds.o adpeval.o adpparse.o adprequest.o auth.o binder.o \
task.o tclcache.o tclcmds.o tclconf.o tclenv.o tclfile.o \
tclhttp.o tclimg.o tclinit.o tcljob.o tclloop.o tclmisc.o \
tclobj.o tclrequest.o tclresp.o tclsched.o tclset.o tclshare.o \
tclsock.o tclthread.o tclvar.o tclxkeylist.o url.o \
tclsock.o tclstore.o tclthread.o tclvar.o tclxkeylist.o url.o \
urlencode.o urlopen.o urlspace.o uuencode.o stamp.o

UNIXOBJS= unix.o
Expand Down
51 changes: 44 additions & 7 deletions nsd/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Manage the Ns_Conn structure
*/

static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nsd/conn.c,v 1.49 2007/09/29 20:08:52 gneumann Exp $, compiled: " __DATE__ " " __TIME__;
static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nsd/conn.c,v 1.50 2009/12/08 04:12:19 jgdavidson Exp $, compiled: " __DATE__ " " __TIME__;

#include "nsd.h"

Expand Down Expand Up @@ -143,7 +143,9 @@ Ns_ConnAuthPasswd(Ns_Conn *conn)
*
* Ns_ConnContentLength --
*
* Get the content length from the client
* Get the content length to be sent from the client.
* Note the data may not have been all received if
* called in a "read" filter callback.
*
* Results:
* An integer content length, or 0 if none sent
Expand All @@ -160,6 +162,33 @@ Ns_ConnContentLength(Ns_Conn *conn)
return conn->contentLength;
}


/*
*----------------------------------------------------------------------
*
* Ns_ConnContentAvail --
*
* Get the content currently available from the client.
* This will generally be all content unless it's called
* during a read filter callback during upload.
*
* Results:
* An integer content length, or 0 if none sent
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/

int
Ns_ConnContentAvail(Ns_Conn *conn)
{
Conn *connPtr = (Conn *) conn;

return connPtr->avail;
}


/*
*----------------------------------------------------------------------
Expand Down Expand Up @@ -1006,26 +1035,26 @@ NsTclConnObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv)
char *content;

static CONST char *opts[] = {
"authpassword", "authuser", "channel", "close", "content", "contentlength",
"contentsentlength",
"authpassword", "authuser", "channel", "close",
"contentavail", "content", "contentlength", "contentsentlength",
"contentchannel", "copy", "driver", "encoding", "files",
"fileoffset", "filelength", "fileheaders", "flags", "form",
"headers", "host", "id", "isconnected", "location", "method",
"outputheaders", "peeraddr", "peerport", "port", "protocol",
"query", "request", "server", "sock", "start", "status",
"url", "urlc", "urlencoding", "urlv", "version",
"write_encoded", NULL
"write_encoded", "interp", NULL
};
enum {
CAuthPasswordIdx, CAuthUserIdx, CChannelIdx, CCloseIdx, CContentIdx,
CAuthPasswordIdx, CAuthUserIdx, CChannelIdx, CCloseIdx, CAvailIdx, CContentIdx,
CContentLengthIdx, CContentSentLenIdx, CContentChannelIdx, CCopyIdx, CDriverIdx,
CEncodingIdx, CFilesIdx, CFileOffIdx, CFileLenIdx,
CFileHdrIdx, CFlagsIdx, CFormIdx, CHeadersIdx, CHostIdx,
CIdIdx, CIsConnectedIdx, CLocationIdx, CMethodIdx,
COutputHeadersIdx, CPeerAddrIdx, CPeerPortIdx, CPortIdx,
CProtocolIdx, CQueryIdx, CRequestIdx, CServerIdx, CSockIdx,
CStartIdx, CStatusIdx, CUrlIdx, CUrlcIdx, CUrlEncodingIdx,
CUrlvIdx, CVersionIdx, CWriteEncodedIdx
CUrlvIdx, CVersionIdx, CWriteEncodedIdx, CInterpIdx
} opt;

if (objc < 2) {
Expand Down Expand Up @@ -1077,6 +1106,10 @@ NsTclConnObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv)
Tcl_SetResult(interp, connPtr->authPasswd, TCL_STATIC);
break;

case CAvailIdx:
Tcl_SetIntObj(result, connPtr->avail);
break;

case CContentChannelIdx:
fd = Ns_ConnContentFd(conn);
if (fd >= 0 && (fd = dup(fd)) >= 0) {
Expand Down Expand Up @@ -1356,6 +1389,10 @@ NsTclConnObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv)
return TCL_ERROR;
}
break;

case CInterpIdx:
Tcl_SetLongObj(result, (long) interp);
break;
}

return TCL_OK;
Expand Down
6 changes: 5 additions & 1 deletion nsd/connio.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Handle connection I/O.
*/

static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nsd/connio.c,v 1.27 2006/04/19 17:48:43 jgdavidson Exp $, compiled: " __DATE__ " " __TIME__;
static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nsd/connio.c,v 1.28 2009/12/08 04:12:19 jgdavidson Exp $, compiled: " __DATE__ " " __TIME__;

#include "nsd.h"
#define IOBUFSZ 2048
Expand Down Expand Up @@ -374,6 +374,10 @@ Ns_ConnSend(Ns_Conn *conn, struct iovec *bufs, int nbufs)

nwrote = n;
}
if (nwrote >= 0
&& NsRunFilters((Ns_Conn *) connPtr, NS_FILTER_WRITE) != NS_OK) {
nwrote = -1;
}
return nwrote;
}

Expand Down
Loading

0 comments on commit 22c0ef3

Please sign in to comment.