- don't overuse CC, split function into wrapper so ones with higher frequency users can retrieve it outside.
* -1 The socket is broken.
* If the socket breaks, the session will be terminated.
*/
* -1 The socket is broken.
* If the socket breaks, the session will be terminated.
*/
-int client_read_to(char *buf, int bytes, int timeout)
+INLINE int client_read_backend(char *buf, int bytes, int timeout, CitContext *CCC)
{
int len,rlen;
fd_set rfds;
{
int len,rlen;
fd_set rfds;
int retval;
#ifdef HAVE_OPENSSL
int retval;
#ifdef HAVE_OPENSSL
- if (CC->redirect_ssl) {
+ if (CCC->redirect_ssl) {
return (client_read_ssl(buf, bytes, timeout));
}
#endif
len = 0;
return (client_read_ssl(buf, bytes, timeout));
}
#endif
len = 0;
- fd = CC->client_socket;
+ fd = CCC->client_socket;
while(len<bytes) {
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
while(len<bytes) {
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
}
else {
CtdlLogPrintf(CTDL_DEBUG, "Failed select() in client_read_to().\n");
}
else {
CtdlLogPrintf(CTDL_DEBUG, "Failed select() in client_read_to().\n");
rlen = read(fd, &buf[len], bytes-len);
if (rlen<1) {
/* The socket has been disconnected! */
rlen = read(fd, &buf[len], bytes-len);
if (rlen<1) {
/* The socket has been disconnected! */
return(-1);
}
len = len + rlen;
return(-1);
}
len = len + rlen;
+
+int client_read_to(char *buf, int bytes, int timeout)
+{
+ return client_read_backend(buf, bytes, timeout, CC);
+}
+
/*
* Read data from the client socket with default timeout.
* (This is implemented in terms of client_read_to() and could be
/*
* Read data from the client socket with default timeout.
* (This is implemented in terms of client_read_to() and could be
int client_getln(char *buf, int bufsize)
{
int i, retval;
int client_getln(char *buf, int bufsize)
{
int i, retval;
/* Read one character at a time.
*/
for (i = 0;;i++) {
/* Read one character at a time.
*/
for (i = 0;;i++) {
- retval = client_read(&buf[i], 1);
+ retval = client_read_backend(&buf[i], 1, config.c_sleeping, CCC);
if (retval != 1 || buf[i] == '\n' || i == (bufsize-1))
break;
}
if (retval != 1 || buf[i] == '\n' || i == (bufsize-1))
break;
}
CtdlDestroyServiceHook();
CtdlDestroyRoomHooks();
#ifdef HAVE_BACKTRACE
CtdlDestroyServiceHook();
CtdlDestroyRoomHooks();
#ifdef HAVE_BACKTRACE