Skip to content

Commit

Permalink
Merge pull request swoole#16 from remicollet/master
Browse files Browse the repository at this point in the history
Merged. Thank you.
  • Loading branch information
matyhtf committed Dec 24, 2013
2 parents 9932de2 + c2a19b6 commit 1c1ed64
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
1 change: 1 addition & 0 deletions include/swoole.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ extern "C" {
#include <sys/mman.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/wait.h>
#include <pthread.h>

#ifdef HAVE_TIMERFD
Expand Down
3 changes: 1 addition & 2 deletions src/network/ProcessPool.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void swProcessPool_shutdown(swProcessPool *pool)
swoole_running = 0;
for (i = 0; i < pool->worker_num; i++)
{
kill(pool->workers[i].pid, SIGTERM);
ret = kill(pool->workers[i].pid, SIGTERM);
if (ret < 0)
{
swWarn("[Manager]kill fail.pid=%d. Error: %s [%d]", pool->workers[i].pid, strerror(errno), errno);
Expand Down Expand Up @@ -128,7 +128,6 @@ static int swProcessPool_worker_start(swProcessPool *pool, swWorker *worker)
int swProcessPool_wait(swProcessPool *pool)
{
int pid, new_pid;
int i, writer_pti;
int reload_worker_i = 0;
int ret;

Expand Down
24 changes: 6 additions & 18 deletions src/network/Server.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static int swServer_poll_onReceive_conn_buffer(swReactor *reactor, swEvent *even
static int swServer_poll_onReceive_data_buffer(swReactor *reactor, swEvent *event);

static void swSignalHanlde(int sig);
static int swConnection_close(swServer *serv, int fd, int *from_id);
static int swConnection_close(swServer *serv, int fd, int16_t *from_id);

static int swServer_single_start(swServer *serv);
static int swServer_single_loop(swProcessPool *pool, swWorker *worker);
Expand All @@ -44,7 +44,7 @@ char swoole_running = 0;
int16_t sw_errno;
char sw_error[SW_ERROR_MSG_SIZE];

SWINLINE int swConnection_close(swServer *serv, int fd, int *from_id)
SWINLINE int swConnection_close(swServer *serv, int fd, int16_t *from_id)
{
swConnection *conn = swServer_get_connection(serv, fd);
swReactor *from_reactor;
Expand Down Expand Up @@ -99,7 +99,8 @@ static int swServer_master_onClose(swReactor *reactor, swEvent *event)
swEventClose cev_queue[SW_CLOSE_QLEN];
swEvent notify_ev;

int i, n, fd, from_id, ret;
int i, n, fd;
int16_t from_id;
n = serv->main_pipe.read(&serv->main_pipe, cev_queue, sizeof(cev_queue));

if (n <= 0)
Expand Down Expand Up @@ -372,7 +373,6 @@ static int swServer_check_callback(swServer *serv)
*/
int swServer_start_base(swServer *serv)
{
int ret;
if (serv->onStart != NULL)
{
serv->onStart(serv);
Expand Down Expand Up @@ -422,11 +422,8 @@ int swServer_start_proxy(swServer *serv)

int swServer_start(swServer *serv)
{
swReactor main_reactor;
swReactor *main_reactor_ptr = &main_reactor;
swFactory *factory = &serv->factory;

struct timeval tmo;
int ret;

ret = swServer_check_callback(serv);
Expand Down Expand Up @@ -615,7 +612,6 @@ int swServer_new_connection(swServer *serv, swEvent *ev)

int swServer_create_base(swServer *serv)
{
int ret = 0;
serv->poll_thread_num = 1;
serv->poll_threads = sw_calloc(1, sizeof(swThreadPoll));
if (serv->poll_threads == NULL)
Expand Down Expand Up @@ -816,7 +812,6 @@ static int swServer_poll_start(swServer *serv, swReactor *main_reactor_ptr)
swThreadParam *param;
swThreadPoll *poll_threads;
pthread_t pidt;
swListenList_node *listen_host;

int i, ret;
//listen UDP
Expand Down Expand Up @@ -909,9 +904,8 @@ int swServer_send_udp_packet(swServer *serv, swSendData *resp)
int swServer_onFinish2(swFactory *factory, swSendData *resp)
{
swServer *serv = factory->ptr;
swThreadPoll *poll_thread = &(serv->poll_threads[resp->info.from_id]);
int ret;
swUdpFd *fd;

//UDP
if (resp->info.from_id >= serv->poll_thread_num)
{
Expand Down Expand Up @@ -986,8 +980,7 @@ static void swServer_single_thread_taskpool(swServer *serv)

static int swServer_single_start(swServer *serv)
{
int i, ret;
int status;
int ret;

swProcessPool pool;
swProcessPool_create(&pool, serv->worker_num, serv->max_request);
Expand Down Expand Up @@ -1038,7 +1031,6 @@ static int swServer_single_start(swServer *serv)

static int swServer_single_loop(swProcessPool *pool, swWorker *worker)
{
int ret;
swServer *serv = pool->ptr;
swReactor *reactor = &(serv->poll_threads[0].reactor);
if (swReactor_auto(reactor, serv->max_conn) < 0)
Expand Down Expand Up @@ -1076,8 +1068,6 @@ static int swServer_single_loop(swProcessPool *pool, swWorker *worker)
static int swServer_single_onClose(swReactor *reactor, swEvent *event)
{
swServer *serv = reactor->ptr;
swFactory *factory = &(serv->factory);
swEvent notify_ev;

if(swConnection_close(serv, event->fd, &(event->from_id)) == 0)
{
Expand Down Expand Up @@ -1544,10 +1534,8 @@ int swServer_addListen(swServer *serv, int type, char *host, int port)
static int swServer_listen(swServer *serv, swReactor *reactor)
{
int sock;
int reactor_i = 0;

swListenList_node *listen_host;
swReactor *poll_reactor;

LL_FOREACH(serv->listen_list, listen_host)
{
Expand Down

0 comments on commit 1c1ed64

Please sign in to comment.