Ejemplo n.º 1
0
int swFactoryProcess_shutdown(swFactory *factory)
{
    swServer *serv = SwooleG.serv;
    int status;

    if (kill(SwooleGS->manager_pid, SIGTERM) < 0)
    {
        swSysError("kill(%d) failed.", SwooleGS->manager_pid);
    }

    if (swWaitpid(SwooleGS->manager_pid, &status, 0) < 0)
    {
        swSysError("waitpid(%d) failed.", SwooleGS->manager_pid);
    }

    if (serv->ipc_mode == SW_IPC_MSGQUEUE)
    {
        swQueueMsg_set_destory(&serv->read_queue, 1);
        serv->read_queue.free(&serv->read_queue);

        swQueueMsg_set_destory(&serv->read_queue, 1);
        serv->write_queue.free(&serv->write_queue);
    }

    //close pipes
    return SW_OK;
}
Ejemplo n.º 2
0
static PHP_METHOD(swoole_process, useQueue)
{
    long msgkey = 0;
    long mode = 2;

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &msgkey, &mode) == FAILURE)
    {
        RETURN_FALSE;
    }

    swWorker *process = swoole_get_object(getThis());

    if (msgkey <= 0)
    {
#if PHP_MAJOR_VERSION == 7
        msgkey = ftok(execute_data->func->op_array.filename->val, 0);
#else
        msgkey = ftok(EG(active_op_array)->filename, 0);
#endif
    }

    swQueue *queue = emalloc(sizeof(swQueue));
    if (swQueueMsg_create(queue, 1, msgkey, 0) < 0)
    {
        RETURN_FALSE;
    }
    swQueueMsg_set_destory(queue, 0);

    process->queue = queue;
    process->ipc_mode = mode;
    RETURN_TRUE;
}