FastCGI Developer's Kit README
------------------------------
- $Id: README,v 1.21 2003/01/19 17:19:41 robs Exp $
+ $Id: README,v 1.22 2003/06/22 00:16:45 robs Exp $
Copyright (c) 1996 Open Market, Inc.
See the file "LICENSE.TERMS" for information on usage and redistribution
of this file, and for a DISCLAIMER OF ALL WARRANTIES.
For more detail regarding changes, please consult the cvs log available
on http://fastcgi.com/.
+2.4.1
+
+ *) Add attach() and detach() support.
+
2.4.0
-----
* See the file "LICENSE.TERMS" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * $Id: fcgiapp.h,v 1.13 2003/02/04 01:31:38 robs Exp $
+ * $Id: fcgiapp.h,v 1.14 2003/06/22 00:16:44 robs Exp $
*/
#ifndef _FCGIAPP_H
int nWriters; /* number of open writers (0..2) */
int flags;
int listen_sock;
+ int detached;
} FCGX_Request;
\f
*/
DLLAPI void FCGX_ShutdownPending(void);
+
+/*
+ * Attach/Detach an accepted request from its listen socket.
+ * XXX This is not fully implemented at this time (patch welcome).
+ */
+DLLAPI int FCGX_Attach(FCGX_Request * r);
+DLLAPI int FCGX_Detach(FCGX_Request * r);
+
+
#if defined (__cplusplus) || defined (c_plusplus)
} /* terminate extern "C" { */
#endif
OS_AsyncProc procPtr, ClientData clientData);
DLLAPI int OS_AsyncWrite(int fd, int offset, void *buf, int len,
OS_AsyncProc procPtr, ClientData clientData);
-DLLAPI int OS_Close(int fd);
+DLLAPI int OS_Close(int fd, int shutdown);
DLLAPI int OS_CloseRead(int fd);
DLLAPI int OS_DoIo(struct timeval *tmo);
DLLAPI int OS_Accept(int listen_sock, int fail_on_intr, const char *webServerAddrs);
-DLLAPI int OS_IpcClose(int ipcFd);
+DLLAPI int OS_IpcClose(int ipcFd, int shutdown);
DLLAPI int OS_IsFcgi(int sock);
DLLAPI void OS_SetFlags(int fd, int flags);
*
*/
#ifndef lint
-static const char rcsid[] = "$Id: fcgiapp.c,v 1.34 2001/12/12 22:54:10 robs Exp $";
+static const char rcsid[] = "$Id: fcgiapp.c,v 1.35 2003/06/22 00:16:43 robs Exp $";
#endif /* not lint */
#include <assert.h>
FreeParams(&request->paramsPtr);
if (close) {
- OS_IpcClose(request->ipcFd);
+ OS_IpcClose(request->ipcFd, ! request->detached);
request->ipcFd = -1;
+ request->detached = 0;
}
}
data->reqDataPtr->appStatus = status;
}
+
+int
+FCGX_Attach(FCGX_Request * r)
+{
+ r->detached = FALSE;
+ return 0;
+}
+
+
+int
+FCGX_Detach(FCGX_Request * r)
+{
+ if (r->ipcFd <= 0)
+ {
+ return -1;
+ }
+
+ r->detached = TRUE;
+ return 0;
+}
*/
#ifndef lint
-static const char rcsid[] = "$Id: os_unix.c,v 1.37 2002/03/05 19:14:49 robs Exp $";
+static const char rcsid[] = "$Id: os_unix.c,v 1.38 2003/06/22 00:16:43 robs Exp $";
#endif /* not lint */
#include "fcgi_config.h"
*
*--------------------------------------------------------------
*/
-int OS_Close(int fd)
+int OS_Close(int fd, int shutdown_ok)
{
if (fd == -1)
return 0;
* cause the client to discard potentially useful response data.
*/
- if (shutdown(fd, 1) == 0)
+ if (shutdown_ok)
{
- struct timeval tv;
- fd_set rfds;
- int rv;
- char trash[1024];
-
- FD_ZERO(&rfds);
-
- do
+ if (shutdown(fd, 1) == 0)
{
- FD_SET(fd, &rfds);
- tv.tv_sec = 2;
- tv.tv_usec = 0;
- rv = select(fd + 1, &rfds, NULL, NULL, &tv);
+ struct timeval tv;
+ fd_set rfds;
+ int rv;
+ char trash[1024];
+
+ FD_ZERO(&rfds);
+
+ do
+ {
+ FD_SET(fd, &rfds);
+ tv.tv_sec = 2;
+ tv.tv_usec = 0;
+ rv = select(fd + 1, &rfds, NULL, NULL, &tv);
+ }
+ while (rv > 0 && read(fd, trash, sizeof(trash)) > 0);
}
- while (rv > 0 && read(fd, trash, sizeof(trash)) > 0);
}
return close(fd);
*
*----------------------------------------------------------------------
*/
-int OS_IpcClose(int ipcFd)
+int OS_IpcClose(int ipcFd, int shutdown)
{
- return OS_Close(ipcFd);
+ return OS_Close(ipcFd, shutdown);
}
/*
* significantly more enjoyable.)
*/
#ifndef lint
-static const char rcsid[] = "$Id: os_win32.c,v 1.33 2002/03/05 18:15:15 robs Exp $";
+static const char rcsid[] = "$Id: os_win32.c,v 1.34 2003/06/22 00:16:43 robs Exp $";
#endif /* not lint */
#define WIN32_LEAN_AND_MEAN
*
*--------------------------------------------------------------
*/
-int OS_Close(int fd)
+int OS_Close(int fd, int shutdown_ok)
{
int ret = 0;
* cause the client to discard potentially useful response data.
*/
- if (shutdown(fdTable[fd].fid.sock, SD_SEND) == 0)
+ if (shutdown_ok)
{
- struct timeval tv;
- fd_set rfds;
- int sock = fdTable[fd].fid.sock;
- int rv;
- char trash[1024];
+ if (shutdown(fdTable[fd].fid.sock, SD_SEND) == 0)
+ {
+ struct timeval tv;
+ fd_set rfds;
+ int sock = fdTable[fd].fid.sock;
+ int rv;
+ char trash[1024];
- FD_ZERO(&rfds);
+ FD_ZERO(&rfds);
- do
- {
- FD_SET(sock, &rfds);
+ do
+ {
+#pragma warning( disable : 4127 )
+ FD_SET((unsigned) sock, &rfds);
+#pragma warning( default : 4127 )
+
tv.tv_sec = 2;
tv.tv_usec = 0;
rv = select(sock + 1, &rfds, NULL, NULL, &tv);
+ }
+ while (rv > 0 && recv(sock, trash, sizeof(trash), 0) > 0);
}
- while (rv > 0 && recv(sock, trash, sizeof(trash), 0) > 0);
}
closesocket(fdTable[fd].fid.sock);
*
*----------------------------------------------------------------------
*/
-int OS_IpcClose(int ipcFd)
+int OS_IpcClose(int ipcFd, int shutdown)
{
if (ipcFd == -1) return 0;
case FD_SOCKET_SYNC:
- OS_Close(ipcFd);
+ OS_Close(ipcFd, shutdown);
break;
case FD_UNUSED: