Created
March 2, 2010 05:25
-
-
Save orlandov/319164 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static int eio_AfterConnect(eio_req *req) { | |
| printf("eio_AfterConnect; rc = %d\n", req->result); | |
| ev_unref(EV_DEFAULT_UC); | |
| } | |
| static int eio_Connect(eio_req *req) { | |
| // Note: this function is executed in the thread pool! CAREFUL | |
| int *foo = (int*)(req->data); | |
| printf("** %p\n", foo); | |
| // this should print 420 but segfaults instead | |
| printf("** %d\n", *(int*)(req->data)); | |
| req->result = 666; | |
| return 0; | |
| } | |
| static Handle<Value> Connect(const Arguments& args) { | |
| HandleScope scope; | |
| int *foo = (int *) malloc(sizeof(int)); | |
| *foo = 420; | |
| printf("foo is %d\n", *foo); | |
| eio_custom(eio_Connect, EIO_PRI_DEFAULT, eio_AfterConnect, foo); | |
| ev_ref(EV_DEFAULT_UC); | |
| return Undefined(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment