diff options
author | David Walter Seikel | 2014-05-14 09:02:51 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-14 09:02:51 +1000 |
commit | 8dc65d54d2c422690852b8bc7d0b7d35ca4582bc (patch) | |
tree | 7cd389f3139cb129f45003e88a172c6804d031ec /src | |
parent | Purkle gets an append command, and use it from extantz to show llSay() and fr... (diff) | |
download | SledjHamr-8dc65d54d2c422690852b8bc7d0b7d35ca4582bc.zip SledjHamr-8dc65d54d2c422690852b8bc7d0b7d35ca4582bc.tar.gz SledjHamr-8dc65d54d2c422690852b8bc7d0b7d35ca4582bc.tar.bz2 SledjHamr-8dc65d54d2c422690852b8bc7d0b7d35ca4582bc.tar.xz |
Starting up and closing down the servers gets some love. Needs more love.
Diffstat (limited to 'src')
-rw-r--r-- | src/LuaSL/LuaSL_main.c | 22 | ||||
-rw-r--r-- | src/extantz/extantz.c | 3 | ||||
-rw-r--r-- | src/love/love.c | 95 |
3 files changed, 56 insertions, 64 deletions
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c index f02c5bf..bfa8728 100644 --- a/src/LuaSL/LuaSL_main.c +++ b/src/LuaSL/LuaSL_main.c | |||
@@ -255,14 +255,16 @@ int main(int argc, char **argv) | |||
255 | if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals))) | 255 | if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals))) |
256 | { | 256 | { |
257 | int i; | 257 | int i; |
258 | Eina_Iterator *scripts; | ||
259 | script *me; | ||
258 | 260 | ||
259 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals); | 261 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals); |
260 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals); | 262 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals); |
261 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals); | 263 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals); |
262 | ecore_con_server_timeout_set(ourGlobals.server, 0); | 264 | ecore_con_server_timeout_set(ourGlobals.server, 0); |
263 | ecore_con_server_client_limit_set(ourGlobals.server, -1, 0); | 265 | ecore_con_server_client_limit_set(ourGlobals.server, -1, 0); |
264 | ecore_con_server_timeout_set(ourGlobals.server, 10); | 266 | // ecore_con_server_timeout_set(ourGlobals.server, 10); |
265 | ecore_con_server_client_limit_set(ourGlobals.server, 3, 0); | 267 | // ecore_con_server_client_limit_set(ourGlobals.server, 3, 0); |
266 | clientStream = eina_strbuf_new(); | 268 | clientStream = eina_strbuf_new(); |
267 | 269 | ||
268 | result = 0; | 270 | result = 0; |
@@ -274,8 +276,21 @@ int main(int argc, char **argv) | |||
274 | PE("Error creating luaproc worker thread."); | 276 | PE("Error creating luaproc worker thread."); |
275 | } | 277 | } |
276 | ecore_main_loop_begin(); | 278 | ecore_main_loop_begin(); |
279 | PD("Fell out of the main loop."); | ||
277 | 280 | ||
278 | // TODO - this is what hangs the system, should change from raw pthreads to ecore threads. | 281 | scripts = eina_hash_iterator_data_new(ourGlobals.scripts); |
282 | while(eina_iterator_next(scripts, (void **) &me)) | ||
283 | { | ||
284 | const char *status = NULL; | ||
285 | |||
286 | status = sendToChannel(&ourGlobals, me->SID, "quit()"); | ||
287 | if (status) | ||
288 | PE("Error sending command quit() to script %s : %s", me->SID, status); | ||
289 | } | ||
290 | |||
291 | PD("Finished quitting scripts."); | ||
292 | // TODO - This is what hangs the system, should change from raw pthreads to ecore threads. | ||
293 | // Or perhaps just run the main loop for a bit longer so all the scripts can quit? | ||
279 | sched_join_workerthreads(); | 294 | sched_join_workerthreads(); |
280 | } | 295 | } |
281 | else | 296 | else |
@@ -292,6 +307,7 @@ int main(int argc, char **argv) | |||
292 | else | 307 | else |
293 | fprintf(stderr, "Failed to init eina!"); | 308 | fprintf(stderr, "Failed to init eina!"); |
294 | 309 | ||
310 | PD("Falling out of main()"); | ||
295 | return result; | 311 | return result; |
296 | } | 312 | } |
297 | 313 | ||
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index 7fce3a3..848bc9a 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c | |||
@@ -76,8 +76,8 @@ static Eina_Bool _del(void *data, int type, Ecore_Con_Event_Server_Del *ev) | |||
76 | 76 | ||
77 | if (ev->server) | 77 | if (ev->server) |
78 | { | 78 | { |
79 | ecore_con_server_del(ourGlobals->server); | ||
79 | ourGlobals->server = NULL; | 80 | ourGlobals->server = NULL; |
80 | ecore_con_server_del(ev->server); | ||
81 | } | 81 | } |
82 | 82 | ||
83 | return ECORE_CALLBACK_RENEW; | 83 | return ECORE_CALLBACK_RENEW; |
@@ -633,6 +633,7 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
633 | // Try to connect to the love server we started before. | 633 | // Try to connect to the love server we started before. |
634 | ourGlobals.address = "127.0.0.1"; | 634 | ourGlobals.address = "127.0.0.1"; |
635 | ourGlobals.port = 8211; | 635 | ourGlobals.port = 8211; |
636 | sleep(2); | ||
636 | if ((ourGlobals.server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port + 1, &ourGlobals))) | 637 | if ((ourGlobals.server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port + 1, &ourGlobals))) |
637 | { | 638 | { |
638 | ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals); | 639 | ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals); |
diff --git a/src/love/love.c b/src/love/love.c index 4d78a8c..e30c292 100644 --- a/src/love/love.c +++ b/src/love/love.c | |||
@@ -59,7 +59,7 @@ static int scriptCount = 0; | |||
59 | static int compiledCount = 0; | 59 | static int compiledCount = 0; |
60 | static float compileTime = 0.0; | 60 | static float compileTime = 0.0; |
61 | static struct timeval startTime; | 61 | static struct timeval startTime; |
62 | static int timedEvent = 0; | 62 | //static int timedEvent = 0; |
63 | static char *ownerKey = "12345678-1234-4321-abcd-0123456789ab"; | 63 | static char *ownerKey = "12345678-1234-4321-abcd-0123456789ab"; |
64 | static char *ownerName = "onefang rejected"; | 64 | static char *ownerName = "onefang rejected"; |
65 | 65 | ||
@@ -176,58 +176,14 @@ static void dirList_compile(const char *name, const char *path, void *data) | |||
176 | 176 | ||
177 | static Eina_Bool _timer_cb(void *data) | 177 | static Eina_Bool _timer_cb(void *data) |
178 | { | 178 | { |
179 | gameGlobals *ourGlobals = data; | 179 | // gameGlobals *ourGlobals = data; |
180 | Eina_Iterator *scripts; | 180 | char buf[PATH_MAX]; |
181 | script *me; | ||
182 | boolean exit = FALSE; | ||
183 | char buf[PATH_MAX]; | ||
184 | |||
185 | if (5 == timedEvent) | ||
186 | { | ||
187 | gettimeofday(&startTime, NULL); | ||
188 | snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR); | ||
189 | eina_file_dir_list(buf, EINA_TRUE, dirList_compile, ourGlobals); | ||
190 | } | ||
191 | |||
192 | if (5 >= timedEvent) | ||
193 | { | ||
194 | timedEvent++; | ||
195 | return ECORE_CALLBACK_RENEW; | ||
196 | } | ||
197 | 181 | ||
198 | scripts = eina_hash_iterator_data_new(ourGlobals->scripts); | 182 | gettimeofday(&startTime, NULL); |
199 | while(eina_iterator_next(scripts, (void **) &me)) | 183 | snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR); |
200 | { | 184 | eina_file_dir_list(buf, EINA_TRUE, dirList_compile, data); |
201 | switch (timedEvent) | ||
202 | { | ||
203 | case 10 : | ||
204 | { | ||
205 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.detectedKeys({\"%s\"})", ownerKey); | ||
206 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.detectedNames({\"%s\"})", ownerName); | ||
207 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.touch_start(1)"); | ||
208 | break; | ||
209 | } | ||
210 | case 15 : | ||
211 | { | ||
212 | sendForth(ourGlobals->serverLuaSL, me->SID, "quit()"); | ||
213 | break; | ||
214 | } | ||
215 | case 20 : | ||
216 | { | ||
217 | exit = TRUE; | ||
218 | break; | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | timedEvent++; | ||
223 | 185 | ||
224 | if (exit) | 186 | return ECORE_CALLBACK_CANCEL; |
225 | { | ||
226 | sendForth(ourGlobals->serverLuaSL, ownerKey, "exit()"); | ||
227 | ecore_main_loop_quit(); | ||
228 | return ECORE_CALLBACK_CANCEL; | ||
229 | } | ||
230 | return ECORE_CALLBACK_RENEW; | ||
231 | } | 187 | } |
232 | 188 | ||
233 | static Eina_Bool _addLuaSL(void *data, int type, Ecore_Con_Event_Server_Add *ev) | 189 | static Eina_Bool _addLuaSL(void *data, int type, Ecore_Con_Event_Server_Add *ev) |
@@ -235,8 +191,8 @@ static Eina_Bool _addLuaSL(void *data, int type, Ecore_Con_Event_Server_Add *ev) | |||
235 | gameGlobals *ourGlobals = data; | 191 | gameGlobals *ourGlobals = data; |
236 | 192 | ||
237 | ourGlobals->serverLuaSL = ev->server; | 193 | ourGlobals->serverLuaSL = ev->server; |
238 | // Wait a while, then start sending events for testing. | 194 | // Wait a while before compiling and running scripts. |
239 | ecore_timer_add(0.5, _timer_cb, ourGlobals); | 195 | ecore_timer_add(3.0, _timer_cb, ourGlobals); |
240 | return ECORE_CALLBACK_RENEW; | 196 | return ECORE_CALLBACK_RENEW; |
241 | } | 197 | } |
242 | 198 | ||
@@ -397,8 +353,6 @@ static Eina_Bool _delLuaSL(void *data, int type, Ecore_Con_Event_Server_Del *ev) | |||
397 | 353 | ||
398 | if (ev->server) | 354 | if (ev->server) |
399 | { | 355 | { |
400 | ourGlobals->serverLuaSL = NULL; | ||
401 | ecore_con_server_del(ev->server); | ||
402 | if (!ourGlobals->ui) | 356 | if (!ourGlobals->ui) |
403 | ecore_main_loop_quit(); | 357 | ecore_main_loop_quit(); |
404 | } | 358 | } |
@@ -507,13 +461,27 @@ static Eina_Bool _dataClient(void *data, int type, Ecore_Con_Event_Client_Data * | |||
507 | 461 | ||
508 | static Eina_Bool _delClient(void *data, int type, Ecore_Con_Event_Client_Del *ev) | 462 | static Eina_Bool _delClient(void *data, int type, Ecore_Con_Event_Client_Del *ev) |
509 | { | 463 | { |
510 | // gameGlobals *ourGlobals = data; | 464 | gameGlobals *ourGlobals = data; |
511 | 465 | ||
512 | if (ev->client) | 466 | if (ev->client) |
513 | { | 467 | { |
514 | PD("No more clients, exiting."); | 468 | Eina_List const *clients; |
515 | ecore_con_client_del(ev->client); | 469 | ecore_con_client_del(ev->client); |
516 | ecore_main_loop_quit(); | 470 | |
471 | // This is only really for testing, normally it just runs 24/7, or until told to. | ||
472 | clients = ecore_con_server_clients_get(ourGlobals->server); | ||
473 | if (0 == eina_list_count(clients)) | ||
474 | { | ||
475 | PD("No more clients, exiting."); | ||
476 | sendForth(ourGlobals->serverLuaSL, ownerKey, "exit()"); | ||
477 | ecore_main_loop_quit(); | ||
478 | } | ||
479 | else | ||
480 | { | ||
481 | PD("Some %d more clients, exiting anyway.", eina_list_count(clients)); | ||
482 | sendForth(ourGlobals->serverLuaSL, ownerKey, "exit()"); | ||
483 | ecore_main_loop_quit(); | ||
484 | } | ||
517 | } | 485 | } |
518 | return ECORE_CALLBACK_RENEW; | 486 | return ECORE_CALLBACK_RENEW; |
519 | } | 487 | } |
@@ -527,6 +495,9 @@ int main(int argc, char **argv) | |||
527 | int result = EXIT_FAILURE; | 495 | int result = EXIT_FAILURE; |
528 | char buf[PATH_MAX]; | 496 | char buf[PATH_MAX]; |
529 | 497 | ||
498 | // TODO - Just a temporary kill command until I can fix the LuaSL hanging on exit bug. | ||
499 | system("killall -KILL LuaSL"); | ||
500 | sleep(2); | ||
530 | sprintf(buf, "%s/LuaSL &", PACKAGE_BIN_DIR); | 501 | sprintf(buf, "%s/LuaSL &", PACKAGE_BIN_DIR); |
531 | system(buf); | 502 | system(buf); |
532 | sleep(1); | 503 | sleep(1); |
@@ -558,8 +529,6 @@ int main(int argc, char **argv) | |||
558 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _delClient, &ourGlobals); | 529 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _delClient, &ourGlobals); |
559 | ecore_con_server_timeout_set(ourGlobals.server, 0); | 530 | ecore_con_server_timeout_set(ourGlobals.server, 0); |
560 | ecore_con_server_client_limit_set(ourGlobals.server, -1, 0); | 531 | ecore_con_server_client_limit_set(ourGlobals.server, -1, 0); |
561 | ecore_con_server_timeout_set(ourGlobals.server, 10); | ||
562 | ecore_con_server_client_limit_set(ourGlobals.server, 3, 0); | ||
563 | clientStream = eina_strbuf_new(); | 532 | clientStream = eina_strbuf_new(); |
564 | 533 | ||
565 | 534 | ||
@@ -675,6 +644,11 @@ int main(int argc, char **argv) | |||
675 | } | 644 | } |
676 | 645 | ||
677 | ecore_main_loop_begin(); | 646 | ecore_main_loop_begin(); |
647 | PD("Fell out of the main loop"); | ||
648 | |||
649 | ecore_con_server_del(ourGlobals.server); | ||
650 | ecore_con_server_del(ourGlobals.serverLuaSL); | ||
651 | |||
678 | if (ourGlobals.ui) | 652 | if (ourGlobals.ui) |
679 | { | 653 | { |
680 | ecore_animator_del(ani); | 654 | ecore_animator_del(ani); |
@@ -706,5 +680,6 @@ int main(int argc, char **argv) | |||
706 | else | 680 | else |
707 | fprintf(stderr, "Failed to init eina!"); | 681 | fprintf(stderr, "Failed to init eina!"); |
708 | 682 | ||
683 | PD("Falling out of main()"); | ||
709 | return result; | 684 | return result; |
710 | } | 685 | } |