put the read buffer back on the stack

SVN revision: 9899
This commit is contained in:
tsauerbeck 2004-04-25 15:52:53 +00:00 committed by tsauerbeck
parent 1e0da5fe44
commit fdff6d615c
2 changed files with 4 additions and 22 deletions

View File

@ -668,7 +668,6 @@ _ecore_con_server_free(Ecore_Con_Server *svr)
#endif #endif
if (svr->name) free(svr->name); if (svr->name) free(svr->name);
if (svr->path) free(svr->path); if (svr->path) free(svr->path);
if (svr->read_buf) free(svr->read_buf);
if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler); if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler);
free(svr); free(svr);
} }
@ -772,12 +771,6 @@ kill_server(Ecore_Con_Server *svr)
svr->dead = 1; svr->dead = 1;
ecore_main_fd_handler_del(svr->fd_handler); ecore_main_fd_handler_del(svr->fd_handler);
svr->fd_handler = NULL; svr->fd_handler = NULL;
if (svr->read_buf)
{
free(svr->read_buf);
svr->read_buf = NULL;
}
} }
static int static int
@ -845,15 +838,13 @@ _ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler)
for (;;) for (;;)
{ {
int num, lost_server = 0; int num, lost_server = 0;
char buf[READBUFSIZ];
#if USE_OPENSSL #if USE_OPENSSL
if (!svr->ssl) if (!svr->ssl)
{ {
#endif #endif
/* FIXME: why is read_buf in the server struct now??? */ if ((num = read(svr->fd, buf, READBUFSIZ)) < 1)
/* yes play nice with ssl - WHY? */
if (!svr->read_buf) svr->read_buf = malloc(READBUFSIZ);
if ((num = read(svr->fd, svr->read_buf, READBUFSIZ)) < 1)
lost_server = (errno == EIO || errno == EBADF || lost_server = (errno == EIO || errno == EBADF ||
errno == EPIPE || errno == EINVAL || errno == EPIPE || errno == EINVAL ||
errno == ENOSPC || num == 0); /* is num == 0 right? */ errno == ENOSPC || num == 0); /* is num == 0 right? */
@ -861,8 +852,7 @@ _ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler)
} }
else else
{ {
if (!svr->read_buf) svr->read_buf = malloc(READBUFSIZ); num = SSL_read(svr->ssl, buf, READBUFSIZ);
num = SSL_read(svr->ssl, svr->read_buf, READBUFSIZ);
if (num < 1) if (num < 1)
{ {
ssl_err = SSL_get_error(svr->ssl, num); ssl_err = SSL_get_error(svr->ssl, num);
@ -899,7 +889,7 @@ _ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler)
else else
{ {
inbuf = realloc(inbuf, inbuf_num + num); inbuf = realloc(inbuf, inbuf_num + num);
memcpy(inbuf + inbuf_num, svr->read_buf, num); memcpy(inbuf + inbuf_num, buf, num);
inbuf_num += num; inbuf_num += num;
} }
} }
@ -937,11 +927,6 @@ _ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler)
_ecore_con_server_flush(svr); _ecore_con_server_flush(svr);
} }
if (svr->read_buf)
{
free(svr->read_buf);
svr->read_buf = NULL;
}
return 1; return 1;
} }

View File

@ -56,9 +56,6 @@ struct _Ecore_Con_Server
char created : 1; char created : 1;
char connecting : 1; char connecting : 1;
/* put the read buffer here to play nice with OpenSSL */
unsigned char *read_buf;
#if USE_OPENSSL #if USE_OPENSSL
SSL_CTX *ssl_ctx; SSL_CTX *ssl_ctx;
SSL *ssl; SSL *ssl;