| 500 | } |
| 501 | |
| 502 | static inline void |
| 503 | ff_handle_socket_ops(struct ff_so_context *sc) |
| 504 | { |
| 505 | #ifdef FF_USE_THREAD_STRUCT_HANDLE |
| 506 | void *old_thread; |
| 507 | void *ff_thread_handle = sc->ff_thread_handle; |
| 508 | #endif |
| 509 | |
| 510 | if (!rte_spinlock_trylock(&sc->lock)) { |
| 511 | return; |
| 512 | } |
| 513 | |
| 514 | if (sc->status != FF_SC_REQ) { |
| 515 | rte_spinlock_unlock(&sc->lock); |
| 516 | return; |
| 517 | } |
| 518 | |
| 519 | DEBUG_LOG("ff_handle_socket_ops sc:%p, status:%d, ops:%d\n", sc, sc->status, sc->ops); |
| 520 | |
| 521 | errno = 0; |
| 522 | #ifdef FF_USE_THREAD_STRUCT_HANDLE |
| 523 | if (ff_thread_handle) { |
| 524 | old_thread = ff_switch_curthread(ff_thread_handle); |
| 525 | } |
| 526 | #endif |
| 527 | sc->result = ff_so_handler(sc->ops, sc->args); |
| 528 | #ifdef FF_USE_THREAD_STRUCT_HANDLE |
| 529 | if (ff_thread_handle) { |
| 530 | ff_restore_curthread(old_thread); |
| 531 | } |
| 532 | #endif |
| 533 | sc->error = errno; |
| 534 | DEBUG_LOG("ff_handle_socket_ops error:%d, ops:%d, result:%d\n", errno, sc->ops, sc->result); |
| 535 | |
| 536 | if (sc->ops == FF_SO_EPOLL_WAIT || sc->ops == FF_SO_KEVENT) { |
| 537 | /*DEBUG_LOG("ff_event_loop_nb:%d, ff_next_event_flag:%d\n", |
| 538 | ff_event_loop_nb, ff_next_event_flag); |
| 539 | if (ff_event_loop_nb > 0) { |
| 540 | ff_next_event_flag = 1; |
| 541 | } else { |
| 542 | ff_next_event_flag = 0; |
| 543 | } |
| 544 | |
| 545 | if (sc->result > 0) { |
| 546 | ff_event_loop_nb = (sc->result * EVENT_LOOP_TIMES); |
| 547 | } else { |
| 548 | ff_event_loop_nb = 0; |
| 549 | }*/ |
| 550 | #ifdef FF_PRELOAD_POLLING_MODE |
| 551 | if (sem_flag == 1 && sc->ops == FF_SO_EPOLL_WAIT) { |
| 552 | sc->status = FF_SC_REP; |
| 553 | } |
| 554 | #else |
| 555 | if (sem_flag == 1) { |
| 556 | sc->status = FF_SC_REP; |
| 557 | sem_post(&sc->wait_sem); |
| 558 | } else { |
| 559 | // do nothing with this sc |
no test coverage detected