zan-extension/src/workers/zanWorker.c
//receive data from networker or taskworker
receive data from networker or taskworker
receive data from networker or taskworker
static int zanWorker_onPipeRead(swReactor *reactor, swEvent *event)
{
    int ret = 0;
    swEventData task;
    zanServer  *serv    = ServerG.serv;
    zanFactory *factory = &serv->factory;
    while (1)
    {
        ret = read(event->fd, &task, sizeof(task));
        if (ret > 0)
        {
            zanDebug("read from pipe_worker=%d, info.type=%d, from_id=%d, from_netid=%d, dst_worker_id=%d, cur_worker_id=%d",
                    event->fd, task.info.type, task.info.from_id, task.info.networker_id, task.info.worker_id, ServerWG.worker_id);
            zanWorker_onTask(factory, &task);
            return ZAN_OK;
        }
        else if (ret < 0 && errno == EAGAIN)
        {
            zanDebug("read from pipe_worker=%d EAGAIN, cur_worker_id=%d, errno=%d:%s", event->fd, ServerWG.worker_id, errno, strerror(errno));
            return ZAN_OK;
        }
        else if (ret < 0 && errno == EINTR)
        {
            zanDebug("read from pipe_worker=%d EINTR, cur_worker_id=%d, errno=%d:%s", event->fd, ServerWG.worker_id, errno, strerror(errno));
            continue;
        }
        else
        {
            zanWarn("read from pipe_worker=%d error, cur_worker_id=%d, errno=%d:%s", event->fd, ServerWG.worker_id, errno, strerror(errno));
            break;
        }
    }
    return ZAN_ERR;
}
static int zanWorker_onPipeRead ( swReactor * reactor , swEvent * event ) { int ret = 0 ; swEventData task ; zanServer * serv = ServerG . serv ; zanFactory * factory = & serv -> factory ; while ( 1 ) { ret = read ( event -> fd , & task , sizeof ( task ) ) ; if ( ret > 0 ) { zanDebug ( " " , event -> fd , task . info . type , task . info . from_id , task . info . networker_id , task . info . worker_id , ServerWG . worker_id ) ; zanWorker_onTask ( factory , & task ) ; return ZAN_OK ; } else if ( ret < 0 && errno == EAGAIN ) { zanDebug ( " " , event -> fd , ServerWG . worker_id , errno , strerror ( errno ) ) ; return ZAN_OK ; } else if ( ret < 0 && errno == EINTR ) { zanDebug ( " " , event -> fd , ServerWG . worker_id , errno , strerror ( errno ) ) ; continue ; } else { zanWarn ( " " , event -> fd , ServerWG . worker_id , errno , strerror ( errno ) ) ; break ; } } return ZAN_ERR ; }
receive data from networker or taskworker
receive data from networker or taskworker