-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
关于hmain与hlog文件的一些问题疑惑与解决方式 #535
Comments
补充一个问题:在使用WebSocketServer时虽然能够通过onopen与onclose实现监控ws会话数,但无法监控父类HttpServer的实际当前tcp连接数,目前还在理解源代码看从哪里着手增加这个监控连接数的功能,也期望作者后面能支持下这个需求。 |
http服务监控TCP连接断开事件已解决 测试正常 大致处理如下 //HttpServer.h的http_server_s中增加两个回调指针
std::function<bool(hio_t* io)> onAccept;
std::function<void(hio_t* io)> onClose;
//HttpHandler.h的HttpHandler中增加一个指针存储
void *user_data;
//HttpServer.cpp的on_close中增加关闭回调触发
http_server_t* server = (http_server_t*)handler->user_data;
...
if (loop) {
if (server->onClose) {
server->onClose(io);
}
--loop->connectionNum;
}
//HttpServer.cpp的on_accept中增加连接回调触发和保存指针
if (server->onAccept) {
if (!server->onAccept(io)) {
hio_close(io);
return;
}
}
++loop->connectionNum;
...
handler->user_data = server; |
首先,感谢你的反馈以及对libhv的认可! 关于HttpServer提供出onAccept和onClose回调,这个后面可以考虑加上。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用的libhv版本:1.3.2
问题1:在 main_ctx_init 处理中Win32判定旧进程是否结束,我遇到最近已终止的pid存在同样能够OpenProcess成功造成误判现象
最后解决方式如下。
问题2:在Win32环境kill_proc采用的TerminateProcess强制终止导致并不触发atexit常规收尾delete_pidfile结束,而代码中也有s_hEventTerm处理的方式,可为什么相关的代码都被注释了,是存在什么问题吗?我是否可以调整为Win32Event处理方式。
问题3:在 main_ctx_init 处理中强制conf/pid/log需读写权限的文件在run_dir运行目录下,导致业务应用在不同的场景启动时运行目录混乱造成错误以及程序在通过exe包admin权限安装后或deb包root权限安装后运行目录并无写入权限造成错误,之后通过调整如下代码支持可以由业务应用优先决定设置run_dir为Win32的%localAppData%或linux的用户home做为数据目录解决。
问题4:在 signal_handle中 处理 "status" 时对已经停止的提示为"%s stop/waiting\n"有语义错误,应该调整为"%s is already stopped\n"
问题5:在业务中使用 signal_handle 感到不利于业务自定义交互形式,因为内部许多直接exit的处理,并且无法得知具体的处理状态,最后通过删除exit并增加具体处理状态的返回值解决。
问题6:在hmain文件中有许多printf做为关键信息提示,但在我的业务中有对不同系统平台自定义的一套信息提示方案,最后是增加一个具体消息用意类型参数并将这些printf调整为printf_callback导出函数指针并默认处理过程为printf直接输出,这样同时也就支持修改为业务所需的自定义处理过程解决。
问题7:某些人或许并不期望自己的业务Release版存在debug输出与源代码信息,是否可以增加编译选项开启使用如下日志形式
The text was updated successfully, but these errors were encountered: