Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example示例错误 #7

Open
ixqbar opened this issue May 14, 2015 · 3 comments
Open

example示例错误 #7

ixqbar opened this issue May 14, 2015 · 3 comments

Comments

@ixqbar
Copy link
Contributor

ixqbar commented May 14, 2015

yar_pack_push_string(packager, "data", 5);
应该为
yar_pack_push_string(packager, "data", 4);

@ixqbar
Copy link
Contributor Author

ixqbar commented Dec 28, 2015

static void yar_server_on_accept(int fd, short ev, void *arg) /* {{{ */ {
    int client_fd;
    struct sockaddr_in client_addr;
    socklen_t client_len = sizeof(struct sockaddr_in);
    yar_request_context *ctx;

    client_fd = accept(fd, (struct sockaddr *)&client_addr, &client_len);

    if (client_fd == -1) {
        return;
    }

    ctx = calloc(1, sizeof(yar_request_context) + sizeof(yar_request) + sizeof(yar_response));
//这里应该是yar_set_non_blocking(client_fd)
    if (!yar_set_non_blocking(fd)) {
        alog(YAR_WARNING, "Setting non-block mode failed '%s'", strerror(errno));
        free(ctx);
        close(client_fd);
        return;
    }

      ...

@ixqbar
Copy link
Contributor Author

ixqbar commented Dec 28, 2015

static int yar_check_previous_run(char *pfile) /* {{{ */ {
    FILE *fp;
    if (access(pfile, F_OK) == 0) {
        alog(YAR_ERROR, "There is already a yar_sever run, pid '%s'", pfile);
        return 0;
    }

    //检查完就写入当前进程pid感觉不太适合,后面的fork也导致了父进程的退出,导致该pid毫无意义
    fp = fopen(pfile, "w+");
    if (!fp) {
        alog(YAR_ERROR, "Failed to write pid file '%s'", strerror(errno));
        return 0;
    }
    fprintf(fp, "%d", getpid());
    fclose(fp);

    return 1;
} /* }}} */

@laruence
Copy link
Owner

你要不然提交个PR过来? 直接修改好的.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants