VirtualBox

Ignore:
Timestamp:
Aug 27, 2013 4:35:28 PM (11 years ago)
Author:
vboxsync
Message:

Drop "fini" callback/arg from tcpip_init() to minimize diffs from
upstream. It's redundant as well. Init callback is necessary because
you want to execute it at the very beginning of tcpip_thread() before
any messages are processed, so normal mbox messages are not suitable
for this.

Instead make termination message (already introduced for VBOX) act as
a callback and use it to pass our fini callback. Rename its message
type to more mnemonic TCPIP_MSG_CALLBACK_TERMINATE.

While here, rototill VBoxLwipCore.cpp to use locking properly and get
rid of global storage for LWIPCOREUSERCALLBACK - since we are waiting
for init/fini callback completion, we can use local variables.

I think VBoxLwipCore.cpp is a bit misguided, since I'm pretty sure
that, for example, you cannot shutdown and then re-init lwip in its
current shape, but for now jsut simplify it as far as we can.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/lwip-new/src/api/tcpip.c

    r47886 r48092  
    5353static tcpip_init_done_fn tcpip_init_done;
    5454static void *tcpip_init_done_arg;
    55 
    56 static tcpip_fini_done_fn tcpip_fini_done;
    57 static void *tcpip_fini_done_arg;
    58 
    5955static sys_mbox_t mbox;
    6056
     
    150146      msg->msg.cb.function(msg->msg.cb.ctx);
    151147      break;
    152 # ifdef VBOX
    153     case TCPIP_MSG_TERM:
    154       UNLOCK_TCPIP_CORE();
     148
     149#ifdef VBOX
     150    case TCPIP_MSG_CALLBACK_TERMINATE:
     151      LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK_TERMINATE %p\n", (void *)msg));
     152      if (msg->msg.cb.function != NULL) {
     153        msg->msg.cb.function(msg->msg.cb.ctx);
     154      }
    155155      goto terminate;
    156 # endif
     156#endif
    157157
    158158    default:
     
    162162    }
    163163  }
    164 # ifdef VBOX
     164#ifdef VBOX
    165165 terminate:
    166   if (tcpip_fini_done != NULL)
    167     tcpip_fini_done(tcpip_fini_done_arg);
     166  /* XXX: TODO: lwip cleanup? */
     167  UNLOCK_TCPIP_CORE();
    168168#endif
    169169}
     
    471471 */
    472472void
    473 #ifdef VBOX
    474 tcpip_init(tcpip_init_done_fn initfunc,
    475            void *init_arg,
    476            tcpip_fini_done_fn finifunc,
    477            void *fini_arg)
    478 #else
    479 tcpip_init(tcpip_init_done_fn initfunc,
    480              void *init_arg)
    481 #endif
     473tcpip_init(tcpip_init_done_fn initfunc, void *arg)
    482474{
    483475  lwip_init();
    484476
    485477  tcpip_init_done = initfunc;
    486   tcpip_init_done_arg = init_arg;
    487 #ifdef VBOX
    488   tcpip_fini_done = finifunc;
    489   tcpip_fini_done_arg = fini_arg;
    490 #endif
     478  tcpip_init_done_arg = arg;
    491479  if(sys_mbox_new(&mbox, TCPIP_MBOX_SIZE) != ERR_OK) {
    492480    LWIP_ASSERT("failed to create tcpip_thread mbox", 0);
     
    539527}
    540528
    541 # ifdef VBOX
    542 void
    543 tcpip_terminate(void)
    544 {
    545   static struct tcpip_msg msg;
    546   msg.type = TCPIP_MSG_TERM;
    547   sys_mbox_post(&mbox, &msg);
    548 }
    549 # endif
    550529#endif /* !NO_SYS */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette