Changeset 5312:27ec111dc8c5 in roaraudio
- Timestamp:
- 11/30/11 01:05:41 (12 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/error.h
r5286 r5312 113 113 void roar_err_to_errno(void); 114 114 115 // Resets the stored state to 'no error' state. This can be used 116 // to init the state. 117 int roar_err_initstore(struct roar_error_state * state); 118 115 119 // store a error state (both libroar and system) 116 120 // returnes the error or ROAR_ERROR_NONE on success so it does not alter gloabl error state. -
include/libroar/roardl.h
r5275 r5312 148 148 int (*func[ROAR_DL_FN_MAX])(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib); 149 149 struct roar_dl_libraryname * libname; 150 size_t global_data_len; 151 void * global_data_init; 152 void ** global_data_pointer; 150 153 }; 151 154 155 // parameter functions: 152 156 struct roar_dl_librarypara * roar_dl_para_new(const char * args, void * binargv, 153 157 const char * appname, const char * abiversion); … … 157 161 const char * appname, const char * abiversion); 158 162 163 // 'core' dynamic loader functions. 159 164 struct roar_dl_lhandle * roar_dl_open (const char * filename, int flags, 160 165 int ra_init, struct roar_dl_librarypara * para); … … 169 174 const char * roar_dl_errstr (struct roar_dl_lhandle * lhandle); 170 175 176 // getting meta data: 171 177 struct roar_dl_librarypara * roar_dl_getpara(struct roar_dl_lhandle * lhandle); 172 178 const struct roar_dl_libraryname * roar_dl_getlibname(struct roar_dl_lhandle * lhandle); 179 180 // context switching: 181 // _restore() is to switch from main to library context. _store() is to store library context 182 // and switch back to main context. 183 int roar_dl_context_restore(struct roar_dl_lhandle * lhandle); 184 int roar_dl_context_store(struct roar_dl_lhandle * lhandle); 173 185 174 186 #endif -
libroar/error.c
r5295 r5312 866 866 } 867 867 868 // Resets the stored state to 'no error' state. This can be used 869 // to init the state. 870 int roar_err_initstore(struct roar_error_state * state) { 871 struct roar_error_state curstate; 872 873 if ( state == NULL ) { 874 roar_err_set(ROAR_ERROR_FAULT); 875 return -1; 876 } 877 878 roar_err_store(&curstate); 879 roar_err_clear_all(); 880 roar_err_store(state); 881 roar_err_restore(&curstate); 882 883 return -1; 884 } 868 885 869 886 // store a error state (both libroar and system) -
libroar/roardl.c
r5275 r5312 43 43 struct roar_dl_librarypara * para; 44 44 struct roar_dl_libraryinst * lib; 45 struct { 46 struct roar_error_state error_state; 47 void * global_data; 48 void * global_data_state; 49 } context; 45 50 #if defined(ROAR_HAVE_LIBDL) 46 51 void * handle; … … 187 192 memset(ret, 0, sizeof(struct roar_dl_lhandle)); 188 193 194 roar_err_initstore(&(ret->context.error_state)); 195 189 196 #if defined(ROAR_HAVE_LIBDL) 190 197 flags = RTLD_NOW; … … 243 250 ret = -1; 244 251 #endif 252 253 if ( lhandle->context.global_data != NULL ) 254 roar_mm_free(lhandle->context.global_data); 245 255 246 256 if ( lhandle->para != NULL ) … … 273 283 struct roar_dl_libraryinst * (*func)(struct roar_dl_librarypara * para); 274 284 struct roar_dl_libraryinst * lib; 285 void * global_data_state = NULL; 275 286 int i; 276 287 … … 310 321 if ( !((void*)lhandle < (void*)128) ) { 311 322 lhandle->lib = lib; 323 324 if ( lib->global_data_len ) { 325 lhandle->context.global_data = roar_mm_malloc(lib->global_data_len); 326 if ( lhandle->context.global_data == NULL ) 327 return -1; 328 329 if ( lib->global_data_init == NULL ) { 330 memset(lhandle->context.global_data, 0, lib->global_data_len); 331 } else { 332 memcpy(lhandle->context.global_data, lib->global_data_init, lib->global_data_len); 333 } 334 } 335 } 336 337 if ( lib->global_data_pointer != NULL ) { 338 global_data_state = *(lib->global_data_pointer); 339 if ( !((void*)lhandle < (void*)128) ) { 340 *(lib->global_data_pointer) = lib->global_data_init; 341 } else { 342 *(lib->global_data_pointer) = lhandle->context.global_data; 343 } 312 344 } 313 345 … … 315 347 if ( lib->func[i] != NULL ) 316 348 lib->func[i](para, lib); 349 } 350 351 if ( lib->global_data_pointer != NULL ) { 352 *(lib->global_data_pointer) = global_data_state; 317 353 } 318 354 … … 375 411 } 376 412 413 int roar_dl_context_restore(struct roar_dl_lhandle * lhandle) { 414 struct roar_error_state error_state; 415 416 if ( (void*)lhandle < (void*)128 ) { 417 roar_err_set(ROAR_ERROR_NOTSUP); 418 return -1; 419 } 420 421 roar_err_store(&error_state); 422 roar_err_restore(&(lhandle->context.error_state)); 423 lhandle->context.error_state = error_state; 424 425 if ( lhandle->lib->global_data_pointer != NULL ) { 426 lhandle->context.global_data_state = *(lhandle->lib->global_data_pointer); 427 *(lhandle->lib->global_data_pointer) = lhandle->context.global_data; 428 } 429 430 return 0; 431 } 432 433 int roar_dl_context_store(struct roar_dl_lhandle * lhandle) { 434 struct roar_error_state error_state; 435 436 if ( (void*)lhandle < (void*)128 ) { 437 roar_err_set(ROAR_ERROR_NOTSUP); 438 return -1; 439 } 440 441 if ( lhandle->lib->global_data_pointer != NULL ) { 442 *(lhandle->lib->global_data_pointer) = lhandle->context.global_data_state; 443 } 444 445 roar_err_store(&error_state); 446 roar_err_restore(&(lhandle->context.error_state)); 447 lhandle->context.error_state = error_state; 448 449 return 0; 450 } 451 377 452 //ll -
plugins/roard/protocol-irc.c
r5310 r5312 865 865 866 866 static struct roard_proto proto[1] = { 867 {ROAR_PROTO_IRC, ROAR_SUBSYS_NONE, "Internet Relay Chat", new_client, check_client, NULL, NULL}867 {ROAR_PROTO_IRC, ROAR_SUBSYS_NONE, "Internet Relay Chat", NULL, new_client, check_client, NULL, NULL} 868 868 }; 869 869 -
plugins/universal/protocol-daytime.c
r5303 r5312 59 59 60 60 static struct roard_proto proto[1] = { 61 {ROAR_PROTO_DAYTIME, ROAR_SUBSYS_NONE, "The Internet daytime protocol", new_client, NULL, NULL, flushed_client}61 {ROAR_PROTO_DAYTIME, ROAR_SUBSYS_NONE, "The Internet daytime protocol", NULL, new_client, NULL, NULL, flushed_client} 62 62 }; 63 63 -
plugins/universal/protocol-discard.c
r5275 r5312 42 42 43 43 static struct roard_proto proto[1] = { 44 {ROAR_PROTO_DISCARD, ROAR_SUBSYS_NONE, "Discard all data send to the server", NULL, check_client, NULL, NULL}44 {ROAR_PROTO_DISCARD, ROAR_SUBSYS_NONE, "Discard all data send to the server", NULL, NULL, check_client, NULL, NULL} 45 45 }; 46 46 -
plugins/universal/protocol-echo.c
r5303 r5312 57 57 58 58 static struct roard_proto proto[1] = { 59 {ROAR_PROTO_ECHO, ROAR_SUBSYS_NONE, "Send all data send to the server back to the client", NULL, check_client, NULL, NULL}59 {ROAR_PROTO_ECHO, ROAR_SUBSYS_NONE, "Send all data send to the server back to the client", NULL, NULL, check_client, NULL, NULL} 60 60 }; 61 61 -
roard/clients.c
r5304 r5312 38 38 #ifndef ROAR_WITHOUT_DCOMP_EMUL_ESD 39 39 #ifdef ROAR_HAVE_H_ESD 40 {ROAR_PROTO_ESOUND, ROAR_SUBSYS_WAVEFORM, "EsounD emulation", NULL, emul_esd_check_client, NULL, NULL},40 {ROAR_PROTO_ESOUND, ROAR_SUBSYS_WAVEFORM, "EsounD emulation", NULL, NULL, emul_esd_check_client, NULL, NULL}, 41 41 #endif 42 42 #endif 43 43 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RPLAY 44 {ROAR_PROTO_RPLAY, ROAR_SUBSYS_WAVEFORM, "RPlay emulation", NULL, emul_rplay_check_client, NULL, NULL},44 {ROAR_PROTO_RPLAY, ROAR_SUBSYS_WAVEFORM, "RPlay emulation", NULL, NULL, emul_rplay_check_client, NULL, NULL}, 45 45 #endif 46 46 #ifndef ROAR_WITHOUT_DCOMP_EMUL_GOPHER 47 {ROAR_PROTO_GOPHER, ROAR_SUBSYS_WAVEFORM, "The Internet Gopher Protocol", NULL, emul_gopher_check_client, NULL, emul_gopher_flushed_client},48 #endif 49 {-1, 0, NULL, NULL, NULL, NULL, NULL }47 {ROAR_PROTO_GOPHER, ROAR_SUBSYS_WAVEFORM, "The Internet Gopher Protocol", NULL, NULL, emul_gopher_check_client, NULL, emul_gopher_flushed_client}, 48 #endif 49 {-1, 0, NULL, NULL, NULL, NULL, NULL, NULL} 50 50 }; 51 51 … … 647 647 if ( g_proto[i].proto == c->proto ) { 648 648 roar_vio_open_fh_socket(&vio, clients_get_fh(id)); 649 if ( g_proto[i].lhandle != NULL ) 650 roar_dl_context_restore(g_proto[i].lhandle); 649 651 rv = g_proto[i].check_client(id, &vio); 652 if ( g_proto[i].lhandle != NULL ) 653 roar_dl_context_store(g_proto[i].lhandle); 650 654 } 651 655 } … … 686 690 687 691 if ( p->flush_client != NULL ) { 692 if ( p->lhandle != NULL ) 693 roar_dl_context_restore(p->lhandle); 688 694 return p->flush_client(id, &vio); 695 if ( p->lhandle != NULL ) 696 roar_dl_context_store(p->lhandle); 689 697 } 690 698 … … 716 724 if ( cs->outbuf == NULL ) { 717 725 if ( p->flushed_client != NULL ) { 726 if ( p->lhandle != NULL ) 727 roar_dl_context_restore(p->lhandle); 718 728 return p->flushed_client(id, &vio); 729 if ( p->lhandle != NULL ) 730 roar_dl_context_store(p->lhandle); 719 731 } 720 732 } … … 813 825 814 826 // proto support 815 int clients_register_proto(struct roard_proto * proto ) {827 int clients_register_proto(struct roard_proto * proto, struct roar_dl_lhandle * lhandle) { 816 828 const size_t len = sizeof(g_proto)/sizeof(*g_proto); 817 829 size_t i; … … 829 841 830 842 memcpy(&(g_proto[i]), proto, sizeof(*g_proto)); 843 844 g_proto[i].lhandle = lhandle; 831 845 832 846 return 0; -
roard/include/client.h
r5301 r5312 78 78 int subsystems; 79 79 const char * description; 80 struct roar_dl_lhandle * lhandle; 80 81 int (*new_client)(int client, struct roar_vio_calls * vio, struct roard_listen * lsock); 81 82 int (*check_client)(int client, struct roar_vio_calls * vio); … … 116 117 117 118 // proto support 118 int clients_register_proto (struct roard_proto * proto );119 int clients_register_proto (struct roard_proto * proto, struct roar_dl_lhandle * lhandle); 119 120 int clients_unregister_proto(int proto); 120 121 void print_protolist (enum output_format format); -
roard/plugins.c
r5275 r5312 57 57 int i; 58 58 59 if ( plugin->sched != NULL ) 60 if ( plugin->sched->free != NULL ) 59 if ( plugin->sched != NULL ) { 60 if ( plugin->sched->free != NULL ) { 61 roar_dl_context_restore(plugin->lhandle); 61 62 plugin->sched->free(); 63 roar_dl_context_store(plugin->lhandle); 64 } 65 } 62 66 63 67 for (i = 0; i < MAX_PROTOS; i++) { … … 87 91 } 88 92 89 if ( g_plugins[i].sched != NULL ) 90 if ( g_plugins[i].sched->init != NULL ) 93 if ( g_plugins[i].sched != NULL ) { 94 if ( g_plugins[i].sched->init != NULL ) { 95 roar_dl_context_restore(g_plugins[i].lhandle); 91 96 g_plugins[i].sched->init(); 97 roar_dl_context_store(g_plugins[i].lhandle); 98 } 99 } 92 100 93 101 _pp = NULL; … … 114 122 int i; 115 123 116 for (i = 0; i < MAX_PLUGINS; i++) 117 if ( g_plugins[i].lhandle != NULL ) 118 if ( g_plugins[i].sched != NULL ) 119 if ( g_plugins[i].sched->update != NULL ) 124 for (i = 0; i < MAX_PLUGINS; i++) { 125 if ( g_plugins[i].lhandle != NULL ) { 126 if ( g_plugins[i].sched != NULL ) { 127 if ( g_plugins[i].sched->update != NULL ) { 128 roar_dl_context_restore(g_plugins[i].lhandle); 120 129 if ( g_plugins[i].sched->update() == -1 ) 121 130 ret = -1; 131 roar_dl_context_store(g_plugins[i].lhandle); 132 } 133 } 134 } 135 } 122 136 123 137 return ret; … … 178 192 } 179 193 180 return clients_register_proto(proto );194 return clients_register_proto(proto, _pp->lhandle); 181 195 } 182 196
Note: See TracChangeset
for help on using the changeset viewer.