| 356 | |
| 357 | |
| 358 | int self_update_routing_script(void) |
| 359 | { |
| 360 | int ret = 0; |
| 361 | |
| 362 | /* be sure we do not overlap with a script reload */ |
| 363 | lock_get( &srr_ctx->lock ); |
| 364 | if (srr_ctx->seq_no!=0) { |
| 365 | LM_INFO("Reload already in progress, cannot update now\n"); |
| 366 | lock_release( &srr_ctx->lock ); |
| 367 | return -1; |
| 368 | } |
| 369 | srr_ctx->seq_no = srr_ctx->next_seq_no++; |
| 370 | lock_release( &srr_ctx->lock ); |
| 371 | |
| 372 | /* anything to reload? */ |
| 373 | if (srr_ctx->reloaded_cfg_buf.s==NULL) |
| 374 | goto done; |
| 375 | |
| 376 | /* put the last reloaded buffer in the right place as for a reload */ |
| 377 | srr_ctx->cfg_buf = srr_ctx->reloaded_cfg_buf; |
| 378 | |
| 379 | routes_reload_per_proc( process_no, (void*)(long)srr_ctx->seq_no); |
| 380 | if (srr_ctx->proc_status[process_no] != RELOAD_SUCCESS) { |
| 381 | LM_ERR("failed to update to the last reloaded cfg :(\n"); |
| 382 | ret = -1; |
| 383 | goto done; |
| 384 | } |
| 385 | |
| 386 | routes_switch_per_proc( process_no, (void*)(long)srr_ctx->seq_no); |
| 387 | |
| 388 | done: |
| 389 | srr_ctx->cfg_buf.s = NULL; |
| 390 | srr_ctx->cfg_buf.len = 0; |
| 391 | /* this must be the last as it will allow the ctx reusage |
| 392 | * for another reload */ |
| 393 | srr_ctx->seq_no = 0; |
| 394 | |
| 395 | return ret; |
| 396 | } |
| 397 | |
| 398 | |
| 399 | /* This is the trigger point for script reloading |
no test coverage detected