Skip to content

Commit

Permalink
Update create buffer_input always.
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Nov 25, 2014
1 parent dd9ff83 commit 4303773
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/network/Worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,28 +300,35 @@ int swWorker_loop(swFactory *factory, int worker_id)
//worker_id
SwooleWG.id = worker_id;

#ifndef SW_USE_RINGBUFFER
int i;
//for open_check_eof and open_check_length

SwooleWG.buffer_input = sw_malloc(sizeof(swString*) * serv->reactor_num);

if (SwooleWG.buffer_input == NULL)
{
swError("malloc for SwooleWG.buffer_input failed.");
return SW_ERR;
}

int buffer_input_size;
if (serv->open_eof_check || serv->open_length_check || serv->open_http_protocol)
{
SwooleWG.buffer_input = sw_malloc(sizeof(swString*) * serv->reactor_num);
if (SwooleWG.buffer_input == NULL)
buffer_input_size = serv->package_max_length;
}
else
{
buffer_input_size = SW_BUFFER_SIZE_BIG;
}

for (i = 0; i < serv->reactor_num; i++)
{
SwooleWG.buffer_input[i] = swString_new(buffer_input_size);
if (SwooleWG.buffer_input[i] == NULL)
{
swError("malloc for SwooleWG.buffer_input failed.");
swError("buffer_input init failed.");
return SW_ERR;
}
for (i = 0; i < serv->reactor_num; i++)
{
SwooleWG.buffer_input[i] = swString_new(serv->buffer_input_size);
if (SwooleWG.buffer_input[i] == NULL)
{
swError("buffer_input init failed.");
return SW_ERR;
}
}
}
#endif

if (serv->ipc_mode == SW_IPC_MSGQUEUE)
{
Expand Down

0 comments on commit 4303773

Please sign in to comment.