We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
nty_coroutine_create(&read_co, server_reader, &cli_fd) cli_fd 为栈变量,复制给co->arg 栈对象的地址不会有问题么?
void server(void *arg) { unsigned short port = *(unsigned short *)arg; free(arg); int fd = nty_socket(AF_INET, SOCK_STREAM, 0); if (fd < 0) return ; struct sockaddr_in local, remote; local.sin_family = AF_INET; local.sin_port = htons(port); local.sin_addr.s_addr = INADDR_ANY; bind(fd, (struct sockaddr*)&local, sizeof(struct sockaddr_in)); listen(fd, 20); printf("listen port : %d\n", port); struct timeval tv_begin; gettimeofday(&tv_begin, NULL); while (1) { socklen_t len = sizeof(struct sockaddr_in); int cli_fd = nty_accept(fd, (struct sockaddr*)&remote, &len); if (cli_fd % 1000 == 999) { struct timeval tv_cur; memcpy(&tv_cur, &tv_begin, sizeof(struct timeval)); gettimeofday(&tv_begin, NULL); int time_used = TIME_SUB_MS(tv_begin, tv_cur); printf("client fd : %d, time_used: %d\n", cli_fd, time_used); } printf("new client comming\n"); nty_coroutine *read_co; // arg 传入一个栈上变量? nty_coroutine_create(&read_co, server_reader, &cli_fd); } }
The text was updated successfully, but these errors were encountered:
貌似while没退出吧?应该是可以的
Sorry, something went wrong.
No branches or pull requests
nty_coroutine_create(&read_co, server_reader, &cli_fd) cli_fd 为栈变量,复制给co->arg 栈对象的地址不会有问题么?
The text was updated successfully, but these errors were encountered: