/*
- * $Id: client_side.cc,v 1.40 1996/10/09 22:49:29 wessels Exp $
+ * $Id: client_side.cc,v 1.41 1996/10/11 23:11:06 wessels Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
}
icpParseRequestHeaders(icpState);
fd_note(fd, icpState->url);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) icpDetectClientClose,
- (void *) icpState);
+ (void *) icpState,
+ 0);
icpProcessRequest(fd, icpState);
}
/*
- * $Id: comm.cc,v 1.87 1996/10/09 22:49:29 wessels Exp $
+ * $Id: comm.cc,v 1.88 1996/10/11 23:11:07 wessels Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
}
switch (comm_connect_addr(fd, &connectState->S)) {
case COMM_INPROGRESS:
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_WRITE,
comm_nbconnect,
- (void *) connectState);
+ (void *) connectState,
+ 0);
break;
case COMM_OK:
connectState->handler(fd, COMM_OK, connectState->data);
}
void
-comm_set_select_handler(int fd, unsigned int type, PF handler, void *client_data)
-{
- comm_set_select_handler_plus_timeout(fd, type, handler, client_data, 0);
-}
-
-void
-comm_set_select_handler_plus_timeout(int fd, unsigned int type, PF handler, void *client_data, time_t timeout)
+commSetSelect(int fd, unsigned int type, PF handler, void *client_data, time_t timeout)
{
if (type & COMM_SELECT_TIMEOUT) {
fd_table[fd].timeout_time = (getCurrentTime() + timeout);
fd_table[fd].timeout_handler = handler;
fd_table[fd].timeout_data = client_data;
if ((timeout <= 0) && handler) {
- debug(5, 2, "comm_set_select_handler_plus_timeout: Zero timeout doesn't make sense\n");
+ debug(5, 2, "commSetSelect: Zero timeout doesn't make sense\n");
}
}
if (type & COMM_SELECT_READ) {
if (len <= 0) {
if (errno == EWOULDBLOCK || errno == EAGAIN) {
/* reschedule self */
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) commHandleRead,
- state);
+ state,
+ 0);
return COMM_OK;
} else {
/* Len == 0 means connection closed; otherwise would not have been
RWStateCallbackAndFree(fd, COMM_OK);
} else {
/* Reschedule until we are done */
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) commHandleRead,
- state);
+ state,
+ 0);
}
return COMM_OK;
}
state->handler_data = handler_data;
state->free = NULL;
fd_table[fd].rwstate = state;
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) commHandleRead,
- state);
+ state,
+ 0);
}
/* Write to FD. */
if (errno == EWOULDBLOCK || errno == EAGAIN) {
debug(5, 10, "commHandleWrite: FD %d: write failure: %s.\n",
fd, xstrerror());
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_WRITE,
(PF) commHandleWrite,
- state);
+ state,
+ 0);
} else {
debug(5, 2, "commHandleWrite: FD %d: write failure: %s.\n",
fd, xstrerror());
state->offset += len;
if (state->offset < state->size) {
/* Not done, reinstall the write handler and write some more */
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_WRITE,
(PF) commHandleWrite,
- state);
+ state,
+ 0);
} else {
RWStateCallbackAndFree(fd, COMM_OK);
}
state->handler_data = handler_data;
state->free = free_func;
fd_table[fd].rwstate = state;
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_WRITE,
(PF) commHandleWrite,
- fd_table[fd].rwstate);
+ fd_table[fd].rwstate,
+ 0);
}
void
/*
- * $Id: disk.cc,v 1.33 1996/10/10 22:20:27 wessels Exp $
+ * $Id: disk.cc,v 1.34 1996/10/11 23:11:09 wessels Exp $
*
* DEBUG: section 6 Disk I/O Routines
* AUTHOR: Harvest Derived
if (len < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* just reschedule us, try again */
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_WRITE,
(PF) diskHandleWrite,
- (void *) entry);
+ (void *) entry,
+ 0);
entry->write_daemon = PRESENT;
return DISK_OK;
} else {
aioFileWriteComplete,
&file_table[fd]);
#else
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_WRITE,
(PF) diskHandleWrite,
- (void *) &file_table[fd]);
+ (void *) &file_table[fd],
+ 0);
return DISK_OK;
#endif
}
/* reschedule if need more data. */
if (ctrl_dat->cur_len < ctrl_dat->req_len) {
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) diskHandleRead,
- (void *) ctrl_dat);
+ (void *) ctrl_dat,
+ 0);
return DISK_OK;
} else {
/* all data we need is here. */
#if USE_ASYNC_IO
return aioFileQueueRead(fd, aioFileReadComplete, ctrl_dat);
#else
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) diskHandleRead,
- (void *) ctrl_dat);
+ (void *) ctrl_dat,
+ 0);
return DISK_OK;
#endif
}
walk_dat->offset += used_bytes;
/* reschedule it for next line. */
- comm_set_select_handler(fd, COMM_SELECT_READ, (PF) diskHandleWalk,
- (void *) walk_dat);
+ commSetSelect(fd, COMM_SELECT_READ, (PF) diskHandleWalk,
+ (void *) walk_dat,
+ 0);
return DISK_OK;
}
walk_dat->line_handler = line_handler;
walk_dat->line_data = line_data;
- comm_set_select_handler(fd, COMM_SELECT_READ, (PF) diskHandleWalk,
- (void *) walk_dat);
+ commSetSelect(fd, COMM_SELECT_READ, (PF) diskHandleWalk,
+ (void *) walk_dat,
+ 0);
return DISK_OK;
}
/*
- * $Id: fqdncache.cc,v 1.25 1996/10/10 22:20:55 wessels Exp $
+ * $Id: fqdncache.cc,v 1.26 1996/10/11 23:11:10 wessels Exp $
*
* DEBUG: section 35 FQDN Cache
* AUTHOR: Harvest Derived
"FD %d: Connection from DNSSERVER #%d is closed, disabling\n",
fd, dnsData->id);
dnsData->flags = 0;
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_WRITE,
NULL,
- NULL);
+ NULL,
+ 0);
comm_close(fd);
return 0;
}
NULL, /* Handler */
NULL, /* Handler-data */
xfree);
- comm_set_select_handler(dns->outpipe,
+ commSetSelect(dns->outpipe,
COMM_SELECT_READ,
(PF) fqdncache_dnsHandleRead,
- dns);
+ dns,
+ 0);
debug(35, 5, "fqdncache_dnsDispatch: Request sent to DNS server #%d.\n",
dns->id);
dns->dispatch_time = current_time;
/*
- * $Id: ftp.cc,v 1.63 1996/10/09 22:49:31 wessels Exp $
+ * $Id: ftp.cc,v 1.64 1996/10/11 23:11:10 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
debug(11, 3, " Current Gap: %d bytes\n", clen - off);
/* reschedule, so it will be automatically reactivated
* when Gap is big enough. */
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) ftpReadReply,
- (void *) data);
+ (void *) data, 0);
if (!BIT_TEST(entry->flag, READ_DEFERRED)) {
/* NOTE there is no read timeout handler to disable */
BIT_SET(entry->flag, READ_DEFERRED);
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* reinstall handlers */
/* XXX This may loop forever */
- comm_set_select_handler(fd, COMM_SELECT_READ,
- (PF) ftpReadReply, (void *) data);
+ commSetSelect(fd, COMM_SELECT_READ,
+ (PF) ftpReadReply, (void *) data, 0);
/* note there is no ftpReadReplyTimeout. Timeouts are handled
* by `ftpget'. */
} else {
/* accept data, but start to delete behind it */
storeStartDeleteBehind(entry);
storeAppend(entry, buf, len);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) ftpReadReply,
- (void *) data);
+ (void *) data, 0);
} else if (entry->flag & CLIENT_ABORT_REQUEST) {
/* append the last bit of info we get */
storeAppend(entry, buf, len);
storeAppend(entry, buf, len);
if (data->reply_hdr_state < 2 && len > 0)
ftpProcessReplyHeader(data, buf, len);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) ftpReadReply,
- (void *) data);
- comm_set_select_handler_plus_timeout(fd,
+ (void *) data, 0);
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
(PF) ftpLifetimeExpire,
(void *) data,
comm_close(fd);
return;
} else {
- comm_set_select_handler(ftpState->ftp_fd,
+ commSetSelect(ftpState->ftp_fd,
COMM_SELECT_READ,
(PF) ftpReadReply,
- (void *) ftpState);
- comm_set_select_handler_plus_timeout(ftpState->ftp_fd,
+ (void *) ftpState, 0);
+ commSetSelect(ftpState->ftp_fd,
COMM_SELECT_TIMEOUT,
(PF) ftpLifetimeExpire,
(void *) ftpState, Config.readTimeout);
(void) fd_note(fd, ftpData->entry->url);
/* Install connection complete handler. */
fd_note(fd, ftpData->entry->url);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_WRITE,
(PF) ftpSendRequest,
- (void *) data);
+ (void *) data, 0);
comm_set_fd_lifetime(fd,
Config.lifetimeDefault);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_LIFETIME,
(PF) ftpLifetimeExpire,
- (void *) ftpData);
+ (void *) ftpData, 0);
if (opt_no_ipcache)
ipcacheInvalidate(ftpData->request->host);
}
* pending */
if (ftpget_server_read < 0)
return;
- comm_set_select_handler(ftpget_server_read,
+ commSetSelect(ftpget_server_read,
COMM_SELECT_READ,
(PF) NULL,
- (void *) NULL);
+ (void *) NULL, 0);
fdstat_close(ftpget_server_read);
close(ftpget_server_read);
fdstat_close(ftpget_server_write);
commSetCloseOnExec(squid_to_ftpget[1]);
commSetCloseOnExec(ftpget_to_squid[0]);
/* if ftpget -S goes away, this handler should get called */
- comm_set_select_handler(ftpget_to_squid[0],
+ commSetSelect(ftpget_to_squid[0],
COMM_SELECT_READ,
(PF) ftpServerClosed,
- (void *) NULL);
+ (void *) NULL, 0);
ftpget_server_write = squid_to_ftpget[1];
ftpget_server_read = ftpget_to_squid[0];
slp.tv_sec = 0;
/*
- * $Id: gopher.cc,v 1.52 1996/10/09 22:49:32 wessels Exp $
+ * $Id: gopher.cc,v 1.53 1996/10/11 23:11:11 wessels Exp $
*
* DEBUG: section 10 Gopher
* AUTHOR: Harvest Derived
entry = data->entry;
debug(10, 4, "gopherLifeTimeExpire: FD %d: <URL:%s>\n", fd, entry->url);
squid_error_entry(entry, ERR_LIFETIME_EXP, NULL);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ | COMM_SELECT_WRITE,
- 0,
- 0);
+ NULL,
+ NULL, 0);
comm_close(fd);
}
-
-
/* This will be called when data is ready to be read from fd. Read until
* error or connection closed. */
static void
debug(10, 3, " Current Gap: %d bytes\n", clen - off);
/* reschedule, so it will automatically reactivated when
* Gap is big enough. */
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) gopherReadReply,
- (void *) data);
+ (void *) data, 0);
/* don't install read timeout until we are below the GAP */
- comm_set_select_handler_plus_timeout(fd,
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
- (PF) NULL,
- (void *) NULL,
- (time_t) 0);
+ NULL,
+ NULL,
+ 0);
if (!BIT_TEST(entry->flag, READ_DEFERRED)) {
comm_set_fd_lifetime(fd, 3600); /* limit during deferring */
BIT_SET(entry->flag, READ_DEFERRED);
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* reinstall handlers */
/* XXX This may loop forever */
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) gopherReadReply,
- (void *) data);
- comm_set_select_handler_plus_timeout(fd,
+ (void *) data, 0);
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
(PF) gopherReadReplyTimeout,
(void *) data,
} else {
storeAppend(entry, buf, len);
}
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) gopherReadReply,
- (void *) data);
- comm_set_select_handler_plus_timeout(fd,
+ (void *) data, 0);
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
(PF) gopherReadReplyTimeout,
(void *) data,
} else {
storeAppend(entry, buf, len);
}
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) gopherReadReply,
- (void *) data);
- comm_set_select_handler_plus_timeout(fd,
+ (void *) data, 0);
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
(PF) gopherReadReplyTimeout,
(void *) data,
}
/* Schedule read reply. */
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) gopherReadReply,
- (void *) gopherState);
- comm_set_select_handler_plus_timeout(fd,
+ (void *) gopherState, 0);
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
(PF) gopherReadReplyTimeout,
(void *) gopherState,
/* Install connection complete handler. */
if (opt_no_ipcache)
ipcacheInvalidate(gopherState->host);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_LIFETIME,
(PF) gopherLifetimeExpire,
- (void *) gopherState);
- comm_set_select_handler(fd,
+ (void *) gopherState, 0);
+ commSetSelect(fd,
COMM_SELECT_WRITE,
(PF) gopherSendRequest,
- (void *) gopherState);
+ (void *) gopherState, 0);
}
/*
- * $Id: http.cc,v 1.82 1996/10/09 22:49:33 wessels Exp $
+ * $Id: http.cc,v 1.83 1996/10/11 23:11:12 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
int ctype;
} ReplyHeaderStats;
-static int httpStateFree _PARAMS((int fd, HttpStateData *));
-static void httpReadReplyTimeout _PARAMS((int fd, HttpStateData *));
-static void httpLifetimeExpire _PARAMS((int fd, HttpStateData *));
+static void httpStateFree _PARAMS((int fd, void *));
+static void httpReadReplyTimeout _PARAMS((int fd, void *));
+static void httpLifetimeExpire _PARAMS((int fd, void *));
static void httpMakePublic _PARAMS((StoreEntry *));
static void httpMakePrivate _PARAMS((StoreEntry *));
static void httpCacheNegatively _PARAMS((StoreEntry *));
-static void httpReadReply _PARAMS((int fd, HttpStateData *));
+static void httpReadReply _PARAMS((int fd, void *));
static void httpSendComplete _PARAMS((int fd, char *, int, int, void *));
-static void httpSendRequest _PARAMS((int fd, HttpStateData *));
+static void httpSendRequest _PARAMS((int fd, void *));
static void httpConnect _PARAMS((int fd, ipcache_addrs *, void *));
static void httpConnectDone _PARAMS((int fd, int status, void *data));
-static int
-httpStateFree(int fd, HttpStateData * httpState)
+static void
+httpStateFree(int fd, void *data)
{
+ HttpStateData *httpState = data;
if (httpState == NULL)
- return 1;
+ return;
storeUnlockObject(httpState->entry);
if (httpState->reply_hdr) {
put_free_8k_page(httpState->reply_hdr);
}
requestUnlink(httpState->request);
xfree(httpState);
- return 0;
}
int
/* This will be called when timeout on read. */
static void
-httpReadReplyTimeout(int fd, HttpStateData * httpState)
+httpReadReplyTimeout(int fd, void *data)
{
+ HttpStateData *httpState = data;
StoreEntry *entry = NULL;
entry = httpState->entry;
debug(11, 4, "httpReadReplyTimeout: FD %d: <URL:%s>\n", fd, entry->url);
squid_error_entry(entry, ERR_READ_TIMEOUT, NULL);
- comm_set_select_handler(fd, COMM_SELECT_READ, 0, 0);
+ commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
comm_close(fd);
}
/* This will be called when socket lifetime is expired. */
static void
-httpLifetimeExpire(int fd, HttpStateData * httpState)
+httpLifetimeExpire(int fd, void *data)
{
+ HttpStateData *httpState = data;
StoreEntry *entry = NULL;
entry = httpState->entry;
debug(11, 4, "httpLifeTimeExpire: FD %d: <URL:%s>\n", fd, entry->url);
squid_error_entry(entry, ERR_LIFETIME_EXP, NULL);
- comm_set_select_handler(fd, COMM_SELECT_READ | COMM_SELECT_WRITE, 0, 0);
+ commSetSelect(fd, COMM_SELECT_READ | COMM_SELECT_WRITE, NULL, NULL, 0);
comm_close(fd);
}
* error or connection closed. */
/* XXX this function is too long! */
static void
-httpReadReply(int fd, HttpStateData * httpState)
+httpReadReply(int fd, void *data)
{
+ HttpStateData *httpState = data;
LOCAL_ARRAY(char, buf, SQUID_TCP_SO_RCVBUF);
int len;
int bin;
debug(11, 3, " Current Gap: %d bytes\n", clen - off);
/* reschedule, so it will be automatically reactivated
* when Gap is big enough. */
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
- (PF) httpReadReply,
- (void *) httpState);
+ httpReadReply,
+ (void *) httpState, 0);
/* disable read timeout until we are below the GAP */
- comm_set_select_handler_plus_timeout(fd,
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
- (PF) NULL,
+ NULL,
(void *) NULL,
(time_t) 0);
if (!BIT_TEST(entry->flag, READ_DEFERRED)) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* reinstall handlers */
/* XXX This may loop forever */
- comm_set_select_handler(fd, COMM_SELECT_READ,
- (PF) httpReadReply, (void *) httpState);
- comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT,
- (PF) httpReadReplyTimeout, (void *) httpState, Config.readTimeout);
+ commSetSelect(fd, COMM_SELECT_READ,
+ httpReadReply, (void *) httpState, 0);
+ commSetSelect(fd, COMM_SELECT_TIMEOUT,
+ httpReadReplyTimeout, (void *) httpState, Config.readTimeout);
} else {
BIT_RESET(entry->flag, ENTRY_CACHABLE);
storeReleaseRequest(entry);
/* accept data, but start to delete behind it */
storeStartDeleteBehind(entry);
storeAppend(entry, buf, len);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
- (PF) httpReadReply,
- (void *) httpState);
- comm_set_select_handler_plus_timeout(fd,
+ httpReadReply,
+ (void *) httpState, 0);
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
- (PF) httpReadReplyTimeout,
+ httpReadReplyTimeout,
(void *) httpState, Config.readTimeout);
} else if (entry->flag & CLIENT_ABORT_REQUEST) {
/* append the last bit of info we get */
if (httpState->reply_hdr_state < 2 && len > 0)
httpProcessReplyHeader(httpState, buf, len);
storeAppend(entry, buf, len);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
- (PF) httpReadReply,
- (void *) httpState);
- comm_set_select_handler_plus_timeout(fd,
+ httpReadReply,
+ (void *) httpState, 0);
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
- (PF) httpReadReplyTimeout,
+ httpReadReplyTimeout,
(void *) httpState,
Config.readTimeout);
}
return;
} else {
/* Schedule read reply. */
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
- (PF) httpReadReply,
- (void *) httpState);
- comm_set_select_handler_plus_timeout(fd,
+ httpReadReply,
+ (void *) httpState, 0);
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
- (PF) httpReadReplyTimeout,
+ httpReadReplyTimeout,
(void *) httpState,
Config.readTimeout);
comm_set_fd_lifetime(fd, 86400); /* extend lifetime */
/* This will be called when connect completes. Write request. */
static void
-httpSendRequest(int fd, HttpStateData * httpState)
+httpSendRequest(int fd, void *data)
{
+ HttpStateData *httpState = data;
char *xbuf = NULL;
char *ybuf = NULL;
char *buf = NULL;
httpState->neighbor = e;
/* register the handler to free HTTP state data when the FD closes */
comm_add_close_handler(sock,
- (PF) httpStateFree,
+ httpStateFree,
(void *) httpState);
request->method = entry->method;
strncpy(request->host, e->host, SQUIDHOSTNAMELEN);
if (opt_no_ipcache)
ipcacheInvalidate(request->host);
fd_note(fd, entry->url);
- comm_set_select_handler(fd, COMM_SELECT_LIFETIME,
- (PF) httpLifetimeExpire, (void *) httpState);
- comm_set_select_handler(fd, COMM_SELECT_WRITE,
- (PF) httpSendRequest, (void *) httpState);
+ commSetSelect(fd, COMM_SELECT_LIFETIME,
+ httpLifetimeExpire, (void *) httpState, 0);
+ commSetSelect(fd, COMM_SELECT_WRITE,
+ httpSendRequest, (void *) httpState, 0);
}
}
httpState->req_hdr_sz = req_hdr_sz;
httpState->request = requestLink(request);
comm_add_close_handler(sock,
- (PF) httpStateFree,
+ httpStateFree,
(void *) httpState);
ipcache_nbgethostbyname(request->host,
sock,
/*
- * $Id: icmp.cc,v 1.18 1996/10/11 19:35:28 wessels Exp $
+ * $Id: icmp.cc,v 1.19 1996/10/11 23:11:12 wessels Exp $
*
* DEBUG: section 37 ICMP Routines
* AUTHOR: Duane Wessels
_exit(1);
}
comm_close(child_sock);
- comm_set_select_handler(icmp_sock,
+ commSetSelect(icmp_sock,
COMM_SELECT_READ,
(PF) icmpRecv,
- (void *) -1);
+ (void *) -1, 0);
comm_set_fd_lifetime(icmp_sock, -1);
debug(29,0,"Pinger socket opened on FD %d\n", icmp_sock);
}
icmpQueueData *queue;
debug(29, 0, "Closing ICMP socket on FD %d\n", icmp_sock);
comm_close(icmp_sock);
- comm_set_select_handler(icmp_sock,
+ commSetSelect(icmp_sock,
COMM_SELECT_READ,
NULL,
- NULL);
+ NULL, 0);
icmp_sock = -1;
while ((queue = IcmpQueueHead)) {
IcmpQueueHead = queue->next;
pingerReplyData preply;
static struct sockaddr_in F;
- comm_set_select_handler(icmp_sock,
+ commSetSelect(icmp_sock,
COMM_SELECT_READ,
(PF) icmpRecv,
- (void *) -1);
+ (void *) -1, 0);
memset((char *) &preply, '\0', sizeof(pingerReplyData));
n = recv(icmp_sock,
(char *) &preply,
q->free_func = free_func;
for (H = &IcmpQueueHead; *H; H = &(*H)->next);
*H = q;
- comm_set_select_handler(icmp_sock,
+ commSetSelect(icmp_sock,
COMM_SELECT_WRITE,
(PF) icmpSend,
- (void *) IcmpQueueHead);
+ (void *) IcmpQueueHead, 0);
}
static void
}
/* Reinstate handler if needed */
if (IcmpQueueHead) {
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_WRITE,
(PF) icmpSend,
- (void *) IcmpQueueHead);
+ (void *) IcmpQueueHead, 0);
} else {
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_WRITE,
NULL,
- NULL);
+ NULL, 0);
}
}
/*
- * $Id: ident.cc,v 1.18 1996/10/10 23:21:28 wessels Exp $
+ * $Id: ident.cc,v 1.19 1996/10/11 23:11:14 wessels Exp $
*
* DEBUG: section 30 Ident (RFC 931)
* AUTHOR: Duane Wessels
identRequestComplete,
(void *) icpState,
NULL);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) identReadReply,
- (void *) icpState);
+ (void *) icpState, 0);
}
static void
/*
- * $Id: ipcache.cc,v 1.70 1996/10/10 22:20:57 wessels Exp $
+ * $Id: ipcache.cc,v 1.71 1996/10/11 23:11:15 wessels Exp $
*
* DEBUG: section 14 IP Cache
* AUTHOR: Harvest Derived
"FD %d: Connection from DNSSERVER #%d is closed, disabling\n",
fd, dnsData->id);
dnsData->flags = 0;
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_WRITE,
NULL,
- NULL);
+ NULL, 0);
comm_close(fd);
return 0;
}
dnsData->flags &= ~DNS_FLAG_BUSY;
}
/* reschedule */
- comm_set_select_handler(dnsData->inpipe,
+ commSetSelect(dnsData->inpipe,
COMM_SELECT_READ,
(PF) ipcache_dnsHandleRead,
- dnsData);
+ dnsData, 0);
while ((dnsData = dnsGetFirstAvailable()) && (i = ipcacheDequeue()))
ipcache_dnsDispatch(dnsData, i);
return 0;
NULL, /* Handler */
NULL, /* Handler-data */
xfree);
- comm_set_select_handler(dns->outpipe,
+ commSetSelect(dns->outpipe,
COMM_SELECT_READ,
(PF) ipcache_dnsHandleRead,
- dns);
+ dns, 0);
debug(14, 5, "ipcache_dnsDispatch: Request sent to DNS server #%d.\n",
dns->id);
dns->dispatch_time = current_time;
/*
- * $Id: main.cc,v 1.91 1996/10/10 22:20:58 wessels Exp $
+ * $Id: main.cc,v 1.92 1996/10/11 23:11:16 wessels Exp $
*
* DEBUG: section 1 Startup and Main Loop
* AUTHOR: Harvest Derived
}
fd_note(theHttpConnection, "HTTP socket");
comm_listen(theHttpConnection);
- comm_set_select_handler(theHttpConnection,
+ commSetSelect(theHttpConnection,
COMM_SELECT_READ,
asciiHandleConn,
- 0);
+ NULL, 0);
debug(1, 1, "Accepting HTTP connections on FD %d.\n",
theHttpConnection);
if (theInIcpConnection < 0)
fatal("Cannot open ICP Port");
fd_note(theInIcpConnection, "ICP socket");
- comm_set_select_handler(theInIcpConnection,
+ commSetSelect(theInIcpConnection,
COMM_SELECT_READ,
icpHandleUdp,
- 0);
+ NULL, 0);
comm_join_mcast_groups(theInIcpConnection);
debug(1, 1, "Accepting ICP connections on FD %d.\n",
theInIcpConnection);
leave_suid();
if (theOutIcpConnection < 0)
fatal("Cannot open Outgoing ICP Port");
- comm_set_select_handler(theOutIcpConnection,
+ commSetSelect(theOutIcpConnection,
COMM_SELECT_READ,
icpHandleUdp,
- 0);
+ NULL, 0);
debug(1, 1, "Accepting ICP connections on FD %d.\n",
theOutIcpConnection);
fd_note(theOutIcpConnection, "Outgoing ICP socket");
debug(21, 1, "FD %d Closing HTTP connection\n",
theHttpConnection);
comm_close(theHttpConnection);
- comm_set_select_handler(theHttpConnection,
+ commSetSelect(theHttpConnection,
COMM_SELECT_READ,
NULL,
- 0);
+ NULL, 0);
theHttpConnection = -1;
}
if (theInIcpConnection >= 0) {
theInIcpConnection);
if (theInIcpConnection != theOutIcpConnection)
comm_close(theInIcpConnection);
- comm_set_select_handler(theInIcpConnection,
+ commSetSelect(theInIcpConnection,
COMM_SELECT_READ,
NULL,
- 0);
+ NULL, 0);
if (theInIcpConnection != theOutIcpConnection)
- comm_set_select_handler(theOutIcpConnection,
+ commSetSelect(theOutIcpConnection,
COMM_SELECT_READ,
NULL,
- 0);
+ NULL, 0);
theInIcpConnection = -1;
}
#if USE_ICMP
/*
- * $Id: redirect.cc,v 1.24 1996/10/10 22:20:30 wessels Exp $
+ * $Id: redirect.cc,v 1.25 1996/10/11 23:11:17 wessels Exp $
*
* DEBUG: section 29 Redirector
* AUTHOR: Duane Wessels
redirector->offset += len;
redirector->inbuf[redirector->offset] = '\0';
/* reschedule */
- comm_set_select_handler(redirector->fd,
+ commSetSelect(redirector->fd,
COMM_SELECT_READ,
(PF) redirectHandleRead,
- redirector);
+ redirector, 0);
if ((t = strchr(redirector->inbuf, '\n'))) {
/* end of record found */
*t = '\0';
fd_note(redirect_child_table[k]->fd, fd_note_buf);
commSetNonBlocking(redirect_child_table[k]->fd);
/* set handler for incoming result */
- comm_set_select_handler(redirect_child_table[k]->fd,
+ commSetSelect(redirect_child_table[k]->fd,
COMM_SELECT_READ,
(PF) redirectHandleRead,
- (void *) redirect_child_table[k]);
+ (void *) redirect_child_table[k], 0);
debug(29, 3, "redirectOpenServers: 'redirect_server' %d started\n",
k);
}
/*
- * $Id: send-announce.cc,v 1.20 1996/10/09 22:49:42 wessels Exp $
+ * $Id: send-announce.cc,v 1.21 1996/10/11 23:11:18 wessels Exp $
*
* DEBUG: section 27 Cache Announcer
* AUTHOR: Duane Wessels
qdata->address.sin_port = htons(port);
qdata->address.sin_addr = ia->in_addrs[0];
AppendUdp(qdata);
- comm_set_select_handler(theOutIcpConnection,
+ commSetSelect(theOutIcpConnection,
COMM_SELECT_WRITE,
(PF) icpUdpReply,
- (void *) qdata);
+ (void *) qdata, 0);
}
/*
- * $Id: ssl.cc,v 1.19 1996/10/09 22:49:42 wessels Exp $
+ * $Id: ssl.cc,v 1.20 1996/10/11 23:11:18 wessels Exp $
*
* DEBUG: section 26 Secure Sockets Layer Proxy
* AUTHOR: Duane Wessels
static char conn_established[] = "HTTP/1.0 200 Connection established\r\n\r\n";
-static void sslLifetimeExpire _PARAMS((int fd, SslStateData * sslState));
-static void sslReadTimeout _PARAMS((int fd, SslStateData * sslState));
-static void sslReadServer _PARAMS((int fd, SslStateData * sslState));
-static void sslReadClient _PARAMS((int fd, SslStateData * sslState));
-static void sslWriteServer _PARAMS((int fd, SslStateData * sslState));
-static void sslWriteClient _PARAMS((int fd, SslStateData * sslState));
-static void sslConnected _PARAMS((int fd, SslStateData * sslState));
-static void sslProxyConnected _PARAMS((int fd, SslStateData * sslState));
+static void sslLifetimeExpire _PARAMS((int fd, void *));
+static void sslReadTimeout _PARAMS((int fd, void *));
+static void sslReadServer _PARAMS((int fd, void *));
+static void sslReadClient _PARAMS((int fd, void *));
+static void sslWriteServer _PARAMS((int fd, void *));
+static void sslWriteClient _PARAMS((int fd, void *));
+static void sslConnected _PARAMS((int fd, void *));
+static void sslProxyConnected _PARAMS((int fd, void *));
static void sslConnect _PARAMS((int fd, ipcache_addrs *, void *));
static void sslErrorComplete _PARAMS((int, char *, int, int, void *));
static void sslClose _PARAMS((SslStateData * sslState));
-static int sslClientClosed _PARAMS((int fd, SslStateData * sslState));
+static void sslClientClosed _PARAMS((int fd, void *));
static void sslConnectDone _PARAMS((int fd, int status, void *data));
+static void sslStateFree _PARAMS((int fd, void *data));
static void
sslClose(SslStateData * sslState)
if (sslState->client.fd > -1) {
/* remove the "unexpected" client close handler */
comm_remove_close_handler(sslState->client.fd,
- (PF) sslClientClosed,
+ sslClientClosed,
(void *) sslState);
comm_close(sslState->client.fd);
sslState->client.fd = -1;
/* This is called only if the client connect closes unexpectedly,
* ie from icpDetectClientClose() */
-static int
-sslClientClosed(int fd, SslStateData * sslState)
+static void
+sslClientClosed(int fd, void *data)
{
+ SslStateData *sslState = data;
debug(26, 3, "sslClientClosed: FD %d\n", fd);
/* we have been called from comm_close for the client side, so
* just need to clean up the server side */
sslState->request,
no_addr);
comm_close(sslState->server.fd);
- return 0;
}
-static int
-sslStateFree(int fd, SslStateData * sslState)
+static void
+sslStateFree(int fd, void *data)
{
+ SslStateData *sslState = data;
debug(26, 3, "sslStateFree: FD %d, sslState=%p\n", fd, sslState);
if (sslState == NULL)
- return 1;
+ return;
if (fd != sslState->server.fd)
fatal_dump("sslStateFree: FD mismatch!\n");
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_READ,
NULL,
- NULL);
+ NULL, 0);
safe_free(sslState->server.buf);
safe_free(sslState->client.buf);
xfree(sslState->url);
requestUnlink(sslState->request);
memset(sslState, '\0', sizeof(SslStateData));
safe_free(sslState);
- return 0;
}
/* This will be called when the server lifetime is expired. */
static void
-sslLifetimeExpire(int fd, SslStateData * sslState)
+sslLifetimeExpire(int fd, void *data)
{
+ SslStateData *sslState = data;
debug(26, 4, "sslLifeTimeExpire: FD %d: URL '%s'>\n",
fd, sslState->url);
sslClose(sslState);
/* Read from server side and queue it for writing to the client */
static void
-sslReadServer(int fd, SslStateData * sslState)
+sslReadServer(int fd, void *data)
{
+ SslStateData *sslState = data;
int len;
len = read(sslState->server.fd, sslState->server.buf, SQUID_TCP_SO_RCVBUF);
debug(26, 5, "sslReadServer FD %d, read %d bytes\n", fd, len);
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* reinstall handlers */
/* XXX This may loop forever */
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_READ,
- (PF) sslReadServer,
- (void *) sslState);
- comm_set_select_handler_plus_timeout(sslState->server.fd,
+ sslReadServer,
+ (void *) sslState, 0);
+ commSetSelect(sslState->server.fd,
COMM_SELECT_TIMEOUT,
- (PF) sslReadTimeout,
+ sslReadTimeout,
(void *) sslState,
sslState->timeout);
} else {
} else {
sslState->server.offset = 0;
sslState->server.len = len;
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_WRITE,
- (PF) sslWriteClient,
- (void *) sslState);
+ sslWriteClient,
+ (void *) sslState, 0);
}
}
/* Read from client side and queue it for writing to the server */
static void
-sslReadClient(int fd, SslStateData * sslState)
+sslReadClient(int fd, void *data)
{
+ SslStateData *sslState = data;
int len;
len = read(sslState->client.fd, sslState->client.buf, SQUID_TCP_SO_RCVBUF);
debug(26, 5, "sslReadClient FD %d, read %d bytes\n",
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* reinstall handlers */
/* XXX This may loop forever */
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_READ,
- (PF) sslReadClient,
- (void *) sslState);
+ sslReadClient,
+ (void *) sslState, 0);
} else {
sslClose(sslState);
}
} else {
sslState->client.offset = 0;
sslState->client.len = len;
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_WRITE,
- (PF) sslWriteServer,
- (void *) sslState);
+ sslWriteServer,
+ (void *) sslState, 0);
}
}
/* Writes data from the client buffer to the server side */
static void
-sslWriteServer(int fd, SslStateData * sslState)
+sslWriteServer(int fd, void *data)
{
+ SslStateData *sslState = data;
int len;
len = write(sslState->server.fd,
sslState->client.buf + sslState->client.offset,
}
if ((sslState->client.offset += len) >= sslState->client.len) {
/* Done writing, read more */
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_READ,
- (PF) sslReadClient,
- (void *) sslState);
- comm_set_select_handler_plus_timeout(sslState->server.fd,
+ sslReadClient,
+ (void *) sslState, 0);
+ commSetSelect(sslState->server.fd,
COMM_SELECT_TIMEOUT,
- (PF) sslReadTimeout,
+ sslReadTimeout,
(void *) sslState,
sslState->timeout);
} else {
/* still have more to write */
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_WRITE,
- (PF) sslWriteServer,
- (void *) sslState);
+ sslWriteServer,
+ (void *) sslState, 0);
}
}
/* Writes data from the server buffer to the client side */
static void
-sslWriteClient(int fd, SslStateData * sslState)
+sslWriteClient(int fd, void *data)
{
+ SslStateData *sslState = data;
int len;
debug(26, 5, "sslWriteClient FD %d len=%d offset=%d\n",
fd,
*sslState->size_ptr += len; /* increment total object size */
if ((sslState->server.offset += len) >= sslState->server.len) {
/* Done writing, read more */
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_READ,
- (PF) sslReadServer,
- (void *) sslState);
+ sslReadServer,
+ (void *) sslState, 0);
} else {
/* still have more to write */
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_WRITE,
- (PF) sslWriteClient,
- (void *) sslState);
+ sslWriteClient,
+ (void *) sslState, 0);
}
}
static void
-sslReadTimeout(int fd, SslStateData * sslState)
+sslReadTimeout(int fd, void *data)
{
+ SslStateData *sslState = data;
debug(26, 3, "sslReadTimeout: FD %d\n", fd);
sslClose(sslState);
}
static void
-sslConnected(int fd, SslStateData * sslState)
+sslConnected(int fd, void *data)
{
+ SslStateData *sslState = data;
debug(26, 3, "sslConnected: FD %d sslState=%p\n", fd, sslState);
strcpy(sslState->server.buf, conn_established);
sslState->server.len = strlen(conn_established);
sslState->server.offset = 0;
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_WRITE,
- (PF) sslWriteClient,
- (void *) sslState);
+ sslWriteClient,
+ (void *) sslState, 0);
comm_set_fd_lifetime(fd, 86400); /* extend lifetime */
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_READ,
- (PF) sslReadClient,
- (void *) sslState);
+ sslReadClient,
+ (void *) sslState, 0);
}
static void
sslState->client.fd,
sslState->server.fd);
/* Install lifetime handler */
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_LIFETIME,
- (PF) sslLifetimeExpire,
- (void *) sslState);
+ sslLifetimeExpire,
+ (void *) sslState, 0);
/* NOTE this changes the lifetime handler for the client side.
* It used to be asciiConnLifetimeHandle, but it does funny things
* like looking for read handlers and assuming it was still reading
* the HTTP request. sigh... */
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_LIFETIME,
- (PF) sslLifetimeExpire,
- (void *) sslState);
+ sslLifetimeExpire,
+ (void *) sslState, 0);
sslState->connectState.fd = fd;
sslState->connectState.host = sslState->host;
sslState->connectState.port = sslState->port;
sslState->port = request->port;
}
comm_add_close_handler(sslState->server.fd,
- (PF) sslStateFree,
+ sslStateFree,
(void *) sslState);
comm_add_close_handler(sslState->client.fd,
- (PF) sslClientClosed,
+ sslClientClosed,
(void *) sslState);
ipcache_nbgethostbyname(sslState->host,
sslState->server.fd,
}
static void
-sslProxyConnected(int fd, SslStateData * sslState)
+sslProxyConnected(int fd, void *data)
{
+ SslStateData *sslState = data;
debug(26, 3, "sslProxyConnected: FD %d sslState=%p\n", fd, sslState);
sprintf(sslState->client.buf, "CONNECT %s HTTP/1.0\r\n\r\n", sslState->url);
debug(26, 3, "sslProxyConnected: Sending 'CONNECT %s HTTP/1.0'\n", sslState->url);
sslState->client.len = strlen(sslState->client.buf);
sslState->client.offset = 0;
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_WRITE,
- (PF) sslWriteServer,
- (void *) sslState);
+ sslWriteServer,
+ (void *) sslState, 0);
comm_set_fd_lifetime(fd, 86400); /* extend lifetime */
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_READ,
- (PF) sslReadServer,
- (void *) sslState);
+ sslReadServer,
+ (void *) sslState, 0);
}
/*
- * $Id: tunnel.cc,v 1.19 1996/10/09 22:49:42 wessels Exp $
+ * $Id: tunnel.cc,v 1.20 1996/10/11 23:11:18 wessels Exp $
*
* DEBUG: section 26 Secure Sockets Layer Proxy
* AUTHOR: Duane Wessels
static char conn_established[] = "HTTP/1.0 200 Connection established\r\n\r\n";
-static void sslLifetimeExpire _PARAMS((int fd, SslStateData * sslState));
-static void sslReadTimeout _PARAMS((int fd, SslStateData * sslState));
-static void sslReadServer _PARAMS((int fd, SslStateData * sslState));
-static void sslReadClient _PARAMS((int fd, SslStateData * sslState));
-static void sslWriteServer _PARAMS((int fd, SslStateData * sslState));
-static void sslWriteClient _PARAMS((int fd, SslStateData * sslState));
-static void sslConnected _PARAMS((int fd, SslStateData * sslState));
-static void sslProxyConnected _PARAMS((int fd, SslStateData * sslState));
+static void sslLifetimeExpire _PARAMS((int fd, void *));
+static void sslReadTimeout _PARAMS((int fd, void *));
+static void sslReadServer _PARAMS((int fd, void *));
+static void sslReadClient _PARAMS((int fd, void *));
+static void sslWriteServer _PARAMS((int fd, void *));
+static void sslWriteClient _PARAMS((int fd, void *));
+static void sslConnected _PARAMS((int fd, void *));
+static void sslProxyConnected _PARAMS((int fd, void *));
static void sslConnect _PARAMS((int fd, ipcache_addrs *, void *));
static void sslErrorComplete _PARAMS((int, char *, int, int, void *));
static void sslClose _PARAMS((SslStateData * sslState));
-static int sslClientClosed _PARAMS((int fd, SslStateData * sslState));
+static void sslClientClosed _PARAMS((int fd, void *));
static void sslConnectDone _PARAMS((int fd, int status, void *data));
+static void sslStateFree _PARAMS((int fd, void *data));
static void
sslClose(SslStateData * sslState)
if (sslState->client.fd > -1) {
/* remove the "unexpected" client close handler */
comm_remove_close_handler(sslState->client.fd,
- (PF) sslClientClosed,
+ sslClientClosed,
(void *) sslState);
comm_close(sslState->client.fd);
sslState->client.fd = -1;
/* This is called only if the client connect closes unexpectedly,
* ie from icpDetectClientClose() */
-static int
-sslClientClosed(int fd, SslStateData * sslState)
+static void
+sslClientClosed(int fd, void *data)
{
+ SslStateData *sslState = data;
debug(26, 3, "sslClientClosed: FD %d\n", fd);
/* we have been called from comm_close for the client side, so
* just need to clean up the server side */
sslState->request,
no_addr);
comm_close(sslState->server.fd);
- return 0;
}
-static int
-sslStateFree(int fd, SslStateData * sslState)
+static void
+sslStateFree(int fd, void *data)
{
+ SslStateData *sslState = data;
debug(26, 3, "sslStateFree: FD %d, sslState=%p\n", fd, sslState);
if (sslState == NULL)
- return 1;
+ return;
if (fd != sslState->server.fd)
fatal_dump("sslStateFree: FD mismatch!\n");
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_READ,
NULL,
- NULL);
+ NULL, 0);
safe_free(sslState->server.buf);
safe_free(sslState->client.buf);
xfree(sslState->url);
requestUnlink(sslState->request);
memset(sslState, '\0', sizeof(SslStateData));
safe_free(sslState);
- return 0;
}
/* This will be called when the server lifetime is expired. */
static void
-sslLifetimeExpire(int fd, SslStateData * sslState)
+sslLifetimeExpire(int fd, void *data)
{
+ SslStateData *sslState = data;
debug(26, 4, "sslLifeTimeExpire: FD %d: URL '%s'>\n",
fd, sslState->url);
sslClose(sslState);
/* Read from server side and queue it for writing to the client */
static void
-sslReadServer(int fd, SslStateData * sslState)
+sslReadServer(int fd, void *data)
{
+ SslStateData *sslState = data;
int len;
len = read(sslState->server.fd, sslState->server.buf, SQUID_TCP_SO_RCVBUF);
debug(26, 5, "sslReadServer FD %d, read %d bytes\n", fd, len);
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* reinstall handlers */
/* XXX This may loop forever */
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_READ,
- (PF) sslReadServer,
- (void *) sslState);
- comm_set_select_handler_plus_timeout(sslState->server.fd,
+ sslReadServer,
+ (void *) sslState, 0);
+ commSetSelect(sslState->server.fd,
COMM_SELECT_TIMEOUT,
- (PF) sslReadTimeout,
+ sslReadTimeout,
(void *) sslState,
sslState->timeout);
} else {
} else {
sslState->server.offset = 0;
sslState->server.len = len;
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_WRITE,
- (PF) sslWriteClient,
- (void *) sslState);
+ sslWriteClient,
+ (void *) sslState, 0);
}
}
/* Read from client side and queue it for writing to the server */
static void
-sslReadClient(int fd, SslStateData * sslState)
+sslReadClient(int fd, void *data)
{
+ SslStateData *sslState = data;
int len;
len = read(sslState->client.fd, sslState->client.buf, SQUID_TCP_SO_RCVBUF);
debug(26, 5, "sslReadClient FD %d, read %d bytes\n",
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* reinstall handlers */
/* XXX This may loop forever */
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_READ,
- (PF) sslReadClient,
- (void *) sslState);
+ sslReadClient,
+ (void *) sslState, 0);
} else {
sslClose(sslState);
}
} else {
sslState->client.offset = 0;
sslState->client.len = len;
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_WRITE,
- (PF) sslWriteServer,
- (void *) sslState);
+ sslWriteServer,
+ (void *) sslState, 0);
}
}
/* Writes data from the client buffer to the server side */
static void
-sslWriteServer(int fd, SslStateData * sslState)
+sslWriteServer(int fd, void *data)
{
+ SslStateData *sslState = data;
int len;
len = write(sslState->server.fd,
sslState->client.buf + sslState->client.offset,
}
if ((sslState->client.offset += len) >= sslState->client.len) {
/* Done writing, read more */
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_READ,
- (PF) sslReadClient,
- (void *) sslState);
- comm_set_select_handler_plus_timeout(sslState->server.fd,
+ sslReadClient,
+ (void *) sslState, 0);
+ commSetSelect(sslState->server.fd,
COMM_SELECT_TIMEOUT,
- (PF) sslReadTimeout,
+ sslReadTimeout,
(void *) sslState,
sslState->timeout);
} else {
/* still have more to write */
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_WRITE,
- (PF) sslWriteServer,
- (void *) sslState);
+ sslWriteServer,
+ (void *) sslState, 0);
}
}
/* Writes data from the server buffer to the client side */
static void
-sslWriteClient(int fd, SslStateData * sslState)
+sslWriteClient(int fd, void *data)
{
+ SslStateData *sslState = data;
int len;
debug(26, 5, "sslWriteClient FD %d len=%d offset=%d\n",
fd,
*sslState->size_ptr += len; /* increment total object size */
if ((sslState->server.offset += len) >= sslState->server.len) {
/* Done writing, read more */
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_READ,
- (PF) sslReadServer,
- (void *) sslState);
+ sslReadServer,
+ (void *) sslState, 0);
} else {
/* still have more to write */
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_WRITE,
- (PF) sslWriteClient,
- (void *) sslState);
+ sslWriteClient,
+ (void *) sslState, 0);
}
}
static void
-sslReadTimeout(int fd, SslStateData * sslState)
+sslReadTimeout(int fd, void *data)
{
+ SslStateData *sslState = data;
debug(26, 3, "sslReadTimeout: FD %d\n", fd);
sslClose(sslState);
}
static void
-sslConnected(int fd, SslStateData * sslState)
+sslConnected(int fd, void *data)
{
+ SslStateData *sslState = data;
debug(26, 3, "sslConnected: FD %d sslState=%p\n", fd, sslState);
strcpy(sslState->server.buf, conn_established);
sslState->server.len = strlen(conn_established);
sslState->server.offset = 0;
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_WRITE,
- (PF) sslWriteClient,
- (void *) sslState);
+ sslWriteClient,
+ (void *) sslState, 0);
comm_set_fd_lifetime(fd, 86400); /* extend lifetime */
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_READ,
- (PF) sslReadClient,
- (void *) sslState);
+ sslReadClient,
+ (void *) sslState, 0);
}
static void
sslState->client.fd,
sslState->server.fd);
/* Install lifetime handler */
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_LIFETIME,
- (PF) sslLifetimeExpire,
- (void *) sslState);
+ sslLifetimeExpire,
+ (void *) sslState, 0);
/* NOTE this changes the lifetime handler for the client side.
* It used to be asciiConnLifetimeHandle, but it does funny things
* like looking for read handlers and assuming it was still reading
* the HTTP request. sigh... */
- comm_set_select_handler(sslState->client.fd,
+ commSetSelect(sslState->client.fd,
COMM_SELECT_LIFETIME,
- (PF) sslLifetimeExpire,
- (void *) sslState);
+ sslLifetimeExpire,
+ (void *) sslState, 0);
sslState->connectState.fd = fd;
sslState->connectState.host = sslState->host;
sslState->connectState.port = sslState->port;
sslState->port = request->port;
}
comm_add_close_handler(sslState->server.fd,
- (PF) sslStateFree,
+ sslStateFree,
(void *) sslState);
comm_add_close_handler(sslState->client.fd,
- (PF) sslClientClosed,
+ sslClientClosed,
(void *) sslState);
ipcache_nbgethostbyname(sslState->host,
sslState->server.fd,
}
static void
-sslProxyConnected(int fd, SslStateData * sslState)
+sslProxyConnected(int fd, void *data)
{
+ SslStateData *sslState = data;
debug(26, 3, "sslProxyConnected: FD %d sslState=%p\n", fd, sslState);
sprintf(sslState->client.buf, "CONNECT %s HTTP/1.0\r\n\r\n", sslState->url);
debug(26, 3, "sslProxyConnected: Sending 'CONNECT %s HTTP/1.0'\n", sslState->url);
sslState->client.len = strlen(sslState->client.buf);
sslState->client.offset = 0;
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_WRITE,
- (PF) sslWriteServer,
- (void *) sslState);
+ sslWriteServer,
+ (void *) sslState, 0);
comm_set_fd_lifetime(fd, 86400); /* extend lifetime */
- comm_set_select_handler(sslState->server.fd,
+ commSetSelect(sslState->server.fd,
COMM_SELECT_READ,
- (PF) sslReadServer,
- (void *) sslState);
+ sslReadServer,
+ (void *) sslState, 0);
}
/*
- * $Id: wais.cc,v 1.45 1996/10/09 22:49:45 wessels Exp $
+ * $Id: wais.cc,v 1.46 1996/10/11 23:11:19 wessels Exp $
*
* DEBUG: section 24 WAIS Relay
* AUTHOR: Harvest Derived
entry = waisState->entry;
debug(24, 4, "waisReadReplyTimeout: Timeout on %d\n url: %s\n", fd, entry->url);
squid_error_entry(entry, ERR_READ_TIMEOUT, NULL);
- comm_set_select_handler(fd, COMM_SELECT_READ, 0, 0);
+ commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
comm_close(fd);
}
entry = waisState->entry;
debug(24, 4, "waisLifeTimeExpire: FD %d: <URL:%s>\n", fd, entry->url);
squid_error_entry(entry, ERR_LIFETIME_EXP, NULL);
- comm_set_select_handler(fd, COMM_SELECT_READ | COMM_SELECT_WRITE, 0, 0);
+ commSetSelect(fd, COMM_SELECT_READ | COMM_SELECT_WRITE, NULL, NULL, 0);
comm_close(fd);
}
debug(24, 3, " Current Gap: %d bytes\n", clen - off);
/* reschedule, so it will automatically reactivated
* when Gap is big enough. */
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) waisReadReply,
- (void *) waisState);
+ (void *) waisState, 0);
/* don't install read handler while we're above the gap */
- comm_set_select_handler_plus_timeout(fd,
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
- (PF) NULL,
- (void *) NULL,
- (time_t) 0);
+ NULL,
+ NULL,
+ 0);
if (!BIT_TEST(entry->flag, READ_DEFERRED)) {
comm_set_fd_lifetime(fd, 3600); /* limit during deferring */
BIT_SET(entry->flag, READ_DEFERRED);
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* reinstall handlers */
/* XXX This may loop forever */
- comm_set_select_handler(fd, COMM_SELECT_READ,
- (PF) waisReadReply, (void *) waisState);
- comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT,
+ commSetSelect(fd, COMM_SELECT_READ,
+ (PF) waisReadReply, (void *) waisState, 0);
+ commSetSelect(fd, COMM_SELECT_TIMEOUT,
(PF) waisReadReplyTimeout, (void *) waisState, Config.readTimeout);
} else {
BIT_RESET(entry->flag, ENTRY_CACHABLE);
/* accept data, but start to delete behind it */
storeStartDeleteBehind(entry);
storeAppend(entry, buf, len);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) waisReadReply,
- (void *) waisState);
- comm_set_select_handler_plus_timeout(fd,
+ (void *) waisState, 0);
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
(PF) waisReadReplyTimeout,
(void *) waisState,
Config.readTimeout);
} else {
storeAppend(entry, buf, len);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) waisReadReply,
- (void *) waisState);
- comm_set_select_handler_plus_timeout(fd,
+ (void *) waisState, 0);
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
(PF) waisReadReplyTimeout,
(void *) waisState,
comm_close(fd);
} else {
/* Schedule read reply. */
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_READ,
(PF) waisReadReply,
- (void *) waisState);
- comm_set_select_handler_plus_timeout(fd,
+ (void *) waisState, 0);
+ commSetSelect(fd,
COMM_SELECT_TIMEOUT,
(PF) waisReadReplyTimeout,
(void *) waisState,
/* Install connection complete handler. */
if (opt_no_ipcache)
ipcacheInvalidate(waisState->relayhost);
- comm_set_select_handler(fd,
+ commSetSelect(fd,
COMM_SELECT_LIFETIME,
(PF) waisLifetimeExpire,
- (void *) waisState);
- comm_set_select_handler(fd,
+ (void *) waisState, 0);
+ commSetSelect(fd,
COMM_SELECT_WRITE,
(PF) waisSendRequest,
- (void *) waisState);
+ (void *) waisState, 0);
}