Changeset 0f81a29f005c4f87e08c22052c27101ab47f8444
- Timestamp:
- 06/25/08 01:58:44
(10 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1214359124 +0000
- git-parent:
[2bdd297562b53dbee111cfefd2101bb9eb99d036]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1214359124 +0000
- Message:
seems to address these. closes #36
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
r3277121 |
r0f81a29 |
|
53 | 53 | return NULL; |
---|
54 | 54 | } |
---|
| 55 | static void |
---|
| 56 | int_cl_free(void *vcl) { |
---|
| 57 | free(vcl); |
---|
| 58 | } |
---|
55 | 59 | |
---|
56 | 60 | static void |
---|
… | … | |
67 | 71 | noitL(nldeb, " remove from eventer system %s\n", |
---|
68 | 72 | removed ? "succeeded" : "failed"); |
---|
| 73 | if(e->closure) { |
---|
| 74 | struct nl_generic_cl *cl; |
---|
| 75 | cl = e->closure; |
---|
| 76 | if(cl->free) cl->free(cl); |
---|
| 77 | } |
---|
69 | 78 | eventer_free(e); |
---|
70 | 79 | free(ev); |
---|
… | … | |
160 | 169 | check = lua_touserdata(L, lua_upvalueindex(1)); |
---|
161 | 170 | ci = check->closure; |
---|
| 171 | /* strdup here... but free later */ |
---|
162 | 172 | ci->current.status = strdup(lua_tostring(L, 1)); |
---|
163 | 173 | return 0; |
---|
… | … | |
474 | 484 | |
---|
475 | 485 | noit_check_set_stats(self, check, &ci->current); |
---|
| 486 | free(ci->current.status); |
---|
476 | 487 | } |
---|
477 | 488 | int |
---|
… | … | |
529 | 540 | struct timeval *now) { |
---|
530 | 541 | noit_check_t *check; |
---|
531 | | noit_lua_check_info_t *ci = closure; |
---|
| 542 | struct nl_intcl *int_cl = closure; |
---|
| 543 | noit_lua_check_info_t *ci = int_cl->ci; |
---|
532 | 544 | check = ci->check; |
---|
533 | 545 | noitL(nldeb, "lua: %p ->check_timeout\n", ci->coro_state); |
---|
… | … | |
548 | 560 | check->flags &= ~NP_RUNNING; |
---|
549 | 561 | } |
---|
| 562 | if(int_cl->free) int_cl->free(int_cl); |
---|
550 | 563 | return 0; |
---|
551 | 564 | } |
---|
… | … | |
553 | 566 | noit_lua_initiate(noit_module_t *self, noit_check_t *check) { |
---|
554 | 567 | LMC_DECL(L, self); |
---|
| 568 | struct nl_intcl *int_cl; |
---|
555 | 569 | noit_lua_check_info_t *ci; |
---|
556 | 570 | struct timeval p_int, __now; |
---|
… | … | |
574 | 588 | e->mask = EVENTER_TIMER; |
---|
575 | 589 | e->callback = noit_lua_check_timeout; |
---|
576 | | e->closure = ci; |
---|
| 590 | /* We wrap this in an alloc so we can blindly free it later */ |
---|
| 591 | int_cl = calloc(1, sizeof(*int_cl)); |
---|
| 592 | int_cl->ci = ci; |
---|
| 593 | int_cl->free = int_cl_free; |
---|
| 594 | e->closure = int_cl; |
---|
577 | 595 | memcpy(&e->whence, &__now, sizeof(__now)); |
---|
578 | 596 | p_int.tv_sec = check->timeout / 1000; |
---|
… | … | |
582 | 600 | eventer_add(e); |
---|
583 | 601 | |
---|
584 | | noitL(nlerr, "initiate gettop => %d\n", lua_gettop(L)); |
---|
| 602 | noitL(nldeb, "initiate gettop => %d\n", lua_gettop(L)); |
---|
585 | 603 | ci->lmc = lmc; |
---|
586 | 604 | lua_getglobal(L, "noit_coros"); |
---|
rc4546c7 |
r0f81a29 |
|
25 | 25 | #endif |
---|
26 | 26 | |
---|
27 | | struct nl_slcl { |
---|
28 | | int send_size; |
---|
29 | | struct timeval start; |
---|
30 | | char *inbuff; |
---|
31 | | int inbuff_allocd; |
---|
32 | | int inbuff_len; |
---|
33 | | size_t read_sofar; |
---|
34 | | size_t read_goal; |
---|
35 | | const char *read_terminator; |
---|
36 | | const char *outbuff; |
---|
37 | | size_t write_sofar; |
---|
38 | | size_t write_goal; |
---|
39 | | eventer_t *eptr; |
---|
40 | | lua_State *L; |
---|
41 | | }; |
---|
42 | | |
---|
| 27 | static void |
---|
| 28 | nl_extended_free(void *vcl) { |
---|
| 29 | struct nl_slcl *cl = vcl; |
---|
| 30 | if(cl->inbuff) free(cl->inbuff); |
---|
| 31 | free(cl); |
---|
| 32 | } |
---|
43 | 33 | static void |
---|
44 | 34 | inbuff_addlstring(struct nl_slcl *cl, const char *b, int l) { |
---|
… | … | |
455 | 445 | p_int = lua_tonumber(L, 1); |
---|
456 | 446 | cl = calloc(1, sizeof(*cl)); |
---|
| 447 | cl->free = nl_extended_free; |
---|
457 | 448 | cl->L = L; |
---|
458 | 449 | gettimeofday(&cl->start, NULL); |
---|
… | … | |
495 | 486 | |
---|
496 | 487 | cl = calloc(1, sizeof(*cl)); |
---|
| 488 | cl->free = nl_extended_free; |
---|
497 | 489 | cl->L = L; |
---|
498 | 490 | |
---|
ra2b666a |
r0f81a29 |
|
40 | 40 | } noit_lua_check_info_t; |
---|
41 | 41 | |
---|
| 42 | struct nl_generic_cl { |
---|
| 43 | void (*free)(void *); |
---|
| 44 | }; |
---|
| 45 | |
---|
| 46 | struct nl_intcl { |
---|
| 47 | void (*free)(void *); |
---|
| 48 | noit_lua_check_info_t *ci; |
---|
| 49 | }; |
---|
| 50 | |
---|
| 51 | struct nl_slcl { |
---|
| 52 | void (*free)(void *); |
---|
| 53 | int send_size; |
---|
| 54 | struct timeval start; |
---|
| 55 | char *inbuff; |
---|
| 56 | int inbuff_allocd; |
---|
| 57 | int inbuff_len; |
---|
| 58 | size_t read_sofar; |
---|
| 59 | size_t read_goal; |
---|
| 60 | const char *read_terminator; |
---|
| 61 | const char *outbuff; |
---|
| 62 | size_t write_sofar; |
---|
| 63 | size_t write_goal; |
---|
| 64 | eventer_t *eptr; |
---|
| 65 | lua_State *L; |
---|
| 66 | }; |
---|
| 67 | |
---|
42 | 68 | int luaopen_noit(lua_State *L); |
---|
43 | 69 | noit_lua_check_info_t *get_ci(lua_State *L); |
---|