libuv

Closing libUV Handles Correctly

人走茶凉 提交于 2019-12-03 04:00:42
问题 I'm trying to find out how to fix these memory leaks I'm getting while running this program with Valgrind. The leaks occur with the two allocations in nShell_client_main . But I'm not sure how to properly free them. I've tried freeing them at nShell_Connect, but it's causing libUV to abort the program. I've tried freeing them at the end of nShell_client_main , but then I get read/write errors when closing the loop. Does anyone know how I'm supposed to close these handles? I've read this,

libev与libuv的区别

匿名 (未验证) 提交于 2019-12-03 00:15:02
libev与libuv的区别 https://www.cnblogs.com/charlesblc/p/6341280.html 参考: http://blog.csdn.net/w616589292/article/details/46475555 libuv libev epoll kqueue libev epoll kqueuq select livev libev accept(3) setnonblocking EAGAIN EWOULDBLOCK EINTER libuv libuv libuv libuv libuv EAGAIN EWOULDBLOCK libuv libev read(3) write(3) libuv 当接口可读时, libuv libuv free 而对写的处理则更显巧妙。 libuv libuv libuv libuv libuv libev void *data libev libuv libev libuv getaddrinfo(3) libev libuv libev IOCP libuv IOCP 参考: http://blog.csdn.net/w616589292/article/details/46475555 libuv libev epoll kqueue libev epoll kqueuq select livev

libev与libuv的区别

最后都变了- 提交于 2019-12-02 04:29:56
libev与libuv的区别 https://www.cnblogs.com/charlesblc/p/6341280.html 参考: http://blog.csdn.net/w616589292/article/details/46475555 libuv 和 libev ,两个名字相当相近的 I/O Library,最近有幸用两个 Library 都写了一些东西,下面就来说一说我本人对两者共同与不同点的主观表述。 高性能网络编程这个话题已经被讨论烂了。异步,异步,还是异步。不管是 epoll 也好, kqueue 也罢,总是免不了异步这个话题。 libev 是系统异步模型的简单封装,基本上来说,它解决了 epoll , kqueuq 与 select 之间 API 不同的问题。保证使用 livev 的 API 编写出的程序可以在大多数 *nix 平台上运行。但是 libev 的缺点也是显而易见,由于基本只是封装了 Event Library,用起来有诸多不便。比如 accept(3) 连接以后需要手动 setnonblocking 。从 socket 读写时需要检测 EAGAIN 、 EWOULDBLOCK 和 EINTER 。这也是大多数人认为异步程序难写的根本原因。 libuv 则显得更为高层。 libuv 是 joyent 给 Node 做的一套 I/O

Variable declarations, using libuv

不羁的心 提交于 2019-12-01 18:59:07
问题 I am trying to learn how to use libuv. I am on a mac OS X and have the library downloaded and installed. I can compile and run small test programs one only starts a callback loop and then exits since there are no watchers, the other creates an idle watcher and exits when the time runs out. I have been trying to go through the samples for the file io and have been running into problems. The function prototype for the function to obtain a file descriptor is: int uv_fs_open(uv_loop_t* loop, uv

libuv undefined reference to uv_loop_new

不问归期 提交于 2019-12-01 17:53:37
After compiling, I am trying to run libuv sample program: #include <stdio.h> #include <uv.h> int main() { uv_loop_t *loop = uv_loop_new(); printf("Now quitting.\n"); uv_run(loop, UV_RUN_DEFAULT); return 0; } But, when try to run, I get the following error: **/tmp/ccHTpspB.o: In function `main': main.c:(.text+0x9): undefined reference to `uv_loop_new' main.c:(.text+0x28): undefined reference to `uv_run' collect2: error: ld returned 1 exit status** Where did I go wrong ? PS: It doesn't work with #include "uv.h" You need to link the libuv.a with your compiled code and the linker doesn't know

Why is stdout buffering?

為{幸葍}努か 提交于 2019-11-30 23:06:39
问题 I am trying to learn the libuv api and wrote the following test: #include <stdio.h> #include <stdlib.h> #include <uv.h> void timer_cb(uv_timer_t* timer) { int* i = timer->data; --*i; if(*i == 0) { uv_timer_stop(timer); } printf("timer %d\n", *i); //fflush(stdout); } int main() { uv_loop_t* loop = uv_default_loop(); uv_timer_t* timer = malloc(sizeof(uv_timer_t)); uv_timer_init(loop, timer); int i = 5; timer->data = &i; uv_timer_start(timer, timer_cb, 1000, 2000); uv_run(loop, UV_RUN_DEFAULT);

你真的了解Event Loop(事件环)吗?

心不动则不痛 提交于 2019-11-30 16:27:25
JS是单线程的 JavaScript语言最大特点就是单线程,但是这里的单线程指的是主线程是单线程的。那为什么js要单线程呢? 因为,JS主要用于操作DOM,如果是有两个线程,一个在DOM上添加内容,一个在DOM上删除内容,此时浏览器该以哪个为准呢? 所以为了避免复杂性,JavaScript从诞生起就是单线程的。 同步和异步 同步和异步关注的是消息通知机制 1)同步在发出调用后,没有结果前是不返回的,一旦调用返回,就得到返回值。调用者会主动等待这个调用结果。 2)异步是发出调用后,调用者不会立刻得到结果,而是被调用者通过状态或回调函数来处理这个调用。 任务队列 因为 JavaScript 是单线程的。就意味着所有任务都需要排队,前一个任务结束,后一个任务才能执行。前一个任务耗时很长,后一个任务也得一直等着。但是IO设备(比如 ajax 网络请求)很慢,CPU一直初一显得状态,这样就很不合理了。 所以,其实主线程完全可以不管IO设备,挂起处于等待中的任务,先运行排在后面的任务。等到IO设备返回了结果,再回过头,把挂起的任务继续执行下去。于是有了 同步任务 和 异步任务 。 同步任务 是指在主线程上执行的任务,只有前一个任务执行完毕,下一个任务才能执行。 异步任务 是指不进入主线程,而是进入 任务队列(task queue) 的任务,只有主线程任务执行完毕, 任务队列

Confusion about node.js internal asynchronous I/O mechanism

↘锁芯ラ 提交于 2019-11-28 17:04:49
I have learned that node.js use libeio internally to perform async file I/O, with thread pool, on *nix platform, am I right? What about async network I/O? Is it done by libev? Is there also a thread pool? If there is thread pool inside, how could it be more efficient than traditional one-thread-per-request model? And is it one thread per I/O request? And what's the mechanism on windows? I know it's done by IOCP, and there's a kernel level thread pool, right? Why linux doesn't have a native completely AIO mechanism like windows IOCP yet? Will it have in future? Update according to changchang's

How is asynchronous javascript interpreted and executed in Node.js?

南笙酒味 提交于 2019-11-28 04:43:28
I've been doing a lot of research into the core of Node.js lately, and I have some questions about the inner workings of the Node platform. As I understand it, Node.js works like this: Node has an API, written in Javascript, that allows the programmer to interact with things like the filesystem and network. However, all of that functionality is actually done by C/C++ code, also a part of Node. Here is where things get a little fuzzy. So it's the Chrome V8 engine's job to essentially "compile"(interpret?) javascript down into machine code. V8 is written in C++, and the Javascript language

What does the “EXDEV: cross-device link not permitted” error mean?

蓝咒 提交于 2019-11-27 17:32:15
问题 What does this error actually mean? What is a "cross-device link"? It is mentioned on this libuv page but it doesn't give any details beyond "cross-device link not permitted". 回答1: It is used for EXDEV on Linux: See man rename manpage: http://man7.org/linux/man-pages/man2/rename.2.html EXDEV oldpath and newpath are not on the same mounted filesystem. (Linux permits a filesystem to be mounted at multiple points, but rename() does not work across different mount points, even if the same