From: adrian <> Date: Sun, 15 Sep 2002 12:23:28 +0000 (+0000) Subject: Tidy up the COMM_OK and COMM_ERR_* magical #define constants into X-Git-Tag: SQUID_3_0_PRE1~758 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d7e9d7ca6c0dc315da45c13b6a855190738a925;p=thirdparty%2Fsquid.git Tidy up the COMM_OK and COMM_ERR_* magical #define constants into an enum, and modify the relevant callback routines to take a comm_err_t as an argument rather than an int. This is prefixed w/ a PRE_COMMLOOPS_20020915 tag. --- diff --git a/src/comm.cc b/src/comm.cc index 72175de363..88d725c05f 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.332 2002/09/12 09:43:51 adrian Exp $ + * $Id: comm.cc,v 1.333 2002/09/15 06:23:28 adrian Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -60,7 +60,7 @@ typedef struct { static int commBind(int s, struct in_addr, u_short port); static void commSetReuseAddr(int); static void commSetNoLinger(int); -static void CommWriteStateCallbackAndFree(int fd, int code); +static void CommWriteStateCallbackAndFree(int fd, comm_err_t code); #ifdef TCP_NODELAY static void commSetTcpNoDelay(int); #endif @@ -69,7 +69,7 @@ static PF commConnectFree; static PF commConnectHandle; static PF commHandleWrite; static IPH commConnectDnsHandle; -static void commConnectCallback(ConnectStateData * cs, int status); +static void commConnectCallback(ConnectStateData * cs, comm_err_t status); static int commResetFD(ConnectStateData * cs); static int commRetryConnect(ConnectStateData * cs); CBDATA_TYPE(ConnectStateData); @@ -78,7 +78,7 @@ static MemPool *comm_write_pool = NULL; static MemPool *conn_close_pool = NULL; static void -CommWriteStateCallbackAndFree(int fd, int code) +CommWriteStateCallbackAndFree(int fd, comm_err_t code) { CommWriteStateData *CommWriteState = fd_table[fd].rwstate; CWCB *callback = NULL; @@ -125,7 +125,7 @@ comm_local_port(int fd) return F->local_port; } -static int +static comm_err_t commBind(int s, struct in_addr in_addr, u_short port) { struct sockaddr_in S; @@ -298,7 +298,7 @@ commConnectDnsHandle(const ipcache_addrs * ia, void *data) } static void -commConnectCallback(ConnectStateData * cs, int status) +commConnectCallback(ConnectStateData * cs, comm_err_t status) { CNCB *callback = cs->callback; void *cbdata = cs->data; @@ -457,7 +457,7 @@ commSetTimeout(int fd, int timeout, PF * handler, void *data) int comm_connect_addr(int sock, const struct sockaddr_in *address) { - int status = COMM_OK; + comm_err_t status = COMM_OK; fde *F = &fd_table[sock]; int x; int err = 0; diff --git a/src/comm_kqueue.cc b/src/comm_kqueue.cc index f37fb1348a..49a5268637 100644 --- a/src/comm_kqueue.cc +++ b/src/comm_kqueue.cc @@ -1,6 +1,6 @@ /* - * $Id: comm_kqueue.cc,v 1.1 2002/01/01 09:47:48 adrian Exp $ + * $Id: comm_kqueue.cc,v 1.2 2002/09/15 06:23:28 adrian Exp $ * * DEBUG: section 5 Socket functions * @@ -217,7 +217,7 @@ commSetSelect(int fd, unsigned int type, PF * handler, * events. */ -int +comm_err_t comm_select(int msec) { int num, i; diff --git a/src/comm_poll.cc b/src/comm_poll.cc index fe199a0c1a..866a73ef9c 100644 --- a/src/comm_poll.cc +++ b/src/comm_poll.cc @@ -1,6 +1,6 @@ /* - * $Id: comm_poll.cc,v 1.3 2002/07/28 21:55:33 hno Exp $ + * $Id: comm_poll.cc,v 1.4 2002/09/15 06:23:28 adrian Exp $ * * DEBUG: section 5 Socket Functions * @@ -307,7 +307,7 @@ comm_poll_http_incoming(void) } /* poll all sockets; call handlers for those that are ready. */ -int +comm_err_t comm_select(int msec) { struct pollfd pfds[SQUID_MAXFD]; diff --git a/src/comm_select.cc b/src/comm_select.cc index 800c540315..7fef8efbe6 100644 --- a/src/comm_select.cc +++ b/src/comm_select.cc @@ -1,6 +1,6 @@ /* - * $Id: comm_select.cc,v 1.57 2002/07/28 21:55:33 hno Exp $ + * $Id: comm_select.cc,v 1.58 2002/09/15 06:23:28 adrian Exp $ * * DEBUG: section 5 Socket Functions * @@ -314,7 +314,7 @@ comm_select_http_incoming(void) #define DEBUG_FDBITS 0 /* Select on all sockets; call handlers for those that are ready. */ -int +comm_err_t comm_select(int msec) { fd_set readfds; diff --git a/src/defines.h b/src/defines.h index b65530c5fc..ee5ae94880 100644 --- a/src/defines.h +++ b/src/defines.h @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.107 2002/08/08 20:12:45 hno Exp $ + * $Id: defines.h,v 1.108 2002/09/15 06:23:29 adrian Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -56,16 +56,6 @@ #define MAXHTTPPORTS 128 -#define COMM_OK (0) -#define COMM_ERROR (-1) -#define COMM_NOMESSAGE (-3) -#define COMM_TIMEOUT (-4) -#define COMM_SHUTDOWN (-5) -#define COMM_INPROGRESS (-6) -#define COMM_ERR_CONNECT (-7) -#define COMM_ERR_DNS (-8) -#define COMM_ERR_CLOSING (-9) - /* Select types. */ #define COMM_SELECT_READ (0x1) #define COMM_SELECT_WRITE (0x2) diff --git a/src/enums.h b/src/enums.h index a2976a95c2..026d90695c 100644 --- a/src/enums.h +++ b/src/enums.h @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.212 2002/09/15 05:41:57 robertc Exp $ + * $Id: enums.h,v 1.213 2002/09/15 06:23:29 adrian Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -752,6 +752,19 @@ typedef enum { DIGEST_READ_DONE } digest_read_state_t; +typedef enum { + COMM_OK = 0, + COMM_ERROR = -1, + COMM_NOMESSAGE = -3, + COMM_TIMEOUT = -4, + COMM_SHUTDOWN = -5, + COMM_INPROGRESS = -6, + COMM_ERR_CONNECT = -7, + COMM_ERR_DNS = -8, + COMM_ERR_CLOSING = -9 +} comm_err_t; + + /* CygWin & Windows NT Port */ #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) /* diff --git a/src/errorpage.cc b/src/errorpage.cc index d4ad5032d1..bda2c501a7 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $Id: errorpage.cc,v 1.175 2002/09/10 09:54:53 hno Exp $ + * $Id: errorpage.cc,v 1.176 2002/09/15 06:23:28 adrian Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -376,7 +376,7 @@ errorSend(int fd, ErrorState * err) * closeing the FD, otherwise we do it ourseves. */ static void -errorSendComplete(int fd, char *bufnotused, size_t size, int errflag, void *data) +errorSendComplete(int fd, char *bufnotused, size_t size, comm_err_t errflag, void *data) { ErrorState *err = data; debug(4, 3) ("errorSendComplete: FD %d, size=%ld\n", fd, (long int) size); diff --git a/src/forward.cc b/src/forward.cc index 2dfff334c3..5e1698bcb5 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -1,6 +1,6 @@ /* - * $Id: forward.cc,v 1.85 2002/06/21 12:58:20 hno Exp $ + * $Id: forward.cc,v 1.86 2002/09/15 06:23:29 adrian Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -177,7 +177,7 @@ fwdServerClosed(int fd, void *data) } static void -fwdConnectDone(int server_fd, int status, void *data) +fwdConnectDone(int server_fd, comm_err_t status, void *data) { FwdState *fwdState = data; static FwdState *current = NULL; diff --git a/src/ftp.cc b/src/ftp.cc index 8ba1037628..99f6fb9841 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.327 2002/09/05 18:07:45 hno Exp $ + * $Id: ftp.cc,v 1.328 2002/09/15 06:23:29 adrian Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -1128,7 +1128,7 @@ ftpWriteCommand(const char *buf, FtpStateData * ftpState) } static void -ftpWriteCommandCallback(int fd, char *bufnotused, size_t size, int errflag, void *data) +ftpWriteCommandCallback(int fd, char *bufnotused, size_t size, comm_err_t errflag, void *data) { FtpStateData *ftpState = data; debug(9, 7) ("ftpWriteCommandCallback: wrote %d bytes\n", (int) size); diff --git a/src/http.cc b/src/http.cc index 385c4f88d1..6a7765ca89 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.390 2002/09/07 22:51:41 hno Exp $ + * $Id: http.cc,v 1.391 2002/09/15 06:23:29 adrian Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -671,7 +671,7 @@ httpReadReply(int fd, void *data) /* This will be called when request write is complete. Schedule read of * reply. */ static void -httpSendComplete(int fd, char *bufnotused, size_t size, int errflag, void *data) +httpSendComplete(int fd, char *bufnotused, size_t size, comm_err_t errflag, void *data) { HttpStateData *httpState = data; StoreEntry *entry = httpState->entry; @@ -1072,7 +1072,7 @@ httpRequestBodyHandler(char *buf, size_t size, void *data) } static void -httpSendRequestEntity(int fd, char *bufnotused, size_t size, int errflag, void *data) +httpSendRequestEntity(int fd, char *bufnotused, size_t size, comm_err_t errflag, void *data) { HttpStateData *httpState = data; StoreEntry *entry = httpState->entry; diff --git a/src/ident.cc b/src/ident.cc index d349bf1384..9a46973f87 100644 --- a/src/ident.cc +++ b/src/ident.cc @@ -1,6 +1,6 @@ /* - * $Id: ident.cc,v 1.59 2002/04/13 23:07:50 hno Exp $ + * $Id: ident.cc,v 1.60 2002/09/15 06:23:29 adrian Exp $ * * DEBUG: section 30 Ident (RFC 931) * AUTHOR: Duane Wessels @@ -98,7 +98,7 @@ identTimeout(int fd, void *data) } static void -identConnectDone(int fd, int status, void *data) +identConnectDone(int fd, comm_err_t status, void *data) { IdentStateData *state = data; IdentClient *c; diff --git a/src/neighbors.cc b/src/neighbors.cc index b6a70462d0..7ef317514e 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.304 2002/08/28 04:40:04 wessels Exp $ + * $Id: neighbors.cc,v 1.305 2002/09/15 06:23:29 adrian Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -1138,7 +1138,7 @@ peerProbeConnect2(const ipcache_addrs * ianotused, void *data) } static void -peerProbeConnectDone(int fd, int status, void *data) +peerProbeConnectDone(int fd, comm_err_t status, void *data) { peer *p = data; if (status == COMM_OK) { diff --git a/src/protos.h b/src/protos.h index 95c2ebf0ff..3a46de272d 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.445 2002/09/15 05:41:57 robertc Exp $ + * $Id: protos.h,v 1.446 2002/09/15 06:23:29 adrian Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -203,7 +203,7 @@ extern int commDeferRead(int fd); * comm_select.c */ extern void comm_select_init(void); -extern int comm_select(int); +extern comm_err_t comm_select(int); extern void comm_quick_poll_required(void); extern void packerToStoreInit(Packer * p, StoreEntry * e); diff --git a/src/ssl.cc b/src/ssl.cc index 5bd20889d9..12a73e8621 100644 --- a/src/ssl.cc +++ b/src/ssl.cc @@ -1,6 +1,6 @@ /* - * $Id: ssl.cc,v 1.120 2002/07/20 12:30:04 hno Exp $ + * $Id: ssl.cc,v 1.121 2002/09/15 06:23:29 adrian Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -381,7 +381,7 @@ sslErrorComplete(int fdnotused, void *data, size_t sizenotused) static void -sslConnectDone(int fdnotused, int status, void *data) +sslConnectDone(int fdnotused, comm_err_t status, void *data) { SslStateData *sslState = data; request_t *request = sslState->request; diff --git a/src/tunnel.cc b/src/tunnel.cc index 5774b7ea62..025f053592 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $Id: tunnel.cc,v 1.120 2002/07/20 12:30:04 hno Exp $ + * $Id: tunnel.cc,v 1.121 2002/09/15 06:23:29 adrian Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -381,7 +381,7 @@ sslErrorComplete(int fdnotused, void *data, size_t sizenotused) static void -sslConnectDone(int fdnotused, int status, void *data) +sslConnectDone(int fdnotused, comm_err_t status, void *data) { SslStateData *sslState = data; request_t *request = sslState->request; diff --git a/src/typedefs.h b/src/typedefs.h index 9b10671960..e635662eed 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.135 2002/09/15 05:41:57 robertc Exp $ + * $Id: typedefs.h,v 1.136 2002/09/15 06:23:29 adrian Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -209,8 +209,8 @@ typedef void CSR(clientStreamNode *, clientHttpRequest *); typedef void CSD(clientStreamNode *, clientHttpRequest *); typedef clientStream_status_t CSS(clientStreamNode *, clientHttpRequest *); -typedef void CWCB(int fd, char *, size_t size, int flag, void *data); -typedef void CNCB(int fd, int status, void *); +typedef void CWCB(int fd, char *, size_t size, comm_err_t flag, void *data); +typedef void CNCB(int fd, comm_err_t status, void *); typedef void FREE(void *); typedef void CBDUNL(void *); diff --git a/src/wais.cc b/src/wais.cc index f75d4bf1aa..c245dfca6f 100644 --- a/src/wais.cc +++ b/src/wais.cc @@ -1,6 +1,6 @@ /* - * $Id: wais.cc,v 1.138 2001/10/24 08:19:09 hno Exp $ + * $Id: wais.cc,v 1.139 2002/09/15 06:23:29 adrian Exp $ * * DEBUG: section 24 WAIS Relay * AUTHOR: Harvest Derived @@ -162,7 +162,7 @@ waisReadReply(int fd, void *data) /* This will be called when request write is complete. Schedule read of * reply. */ static void -waisSendComplete(int fd, char *bufnotused, size_t size, int errflag, void *data) +waisSendComplete(int fd, char *bufnotused, size_t size, comm_err_t errflag, void *data) { WaisStateData *waisState = data; StoreEntry *entry = waisState->entry;