VirtualBox

Changeset 60532 in vbox for trunk/src


Ignore:
Timestamp:
Apr 18, 2016 9:24:40 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
106656
Message:

webservice: Speed up termination (and also trigger proper cleanup for SIGTERM), should be now well below 1 second. Play safe in the service scripts and wait for a second on service termination, to give it time to clean up. Otherwise a service restart can fail for no good reason.

Location:
trunk/src/VBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/linux/vboxweb-service.sh

    r58326 r60532  
    168168        killproc $binary
    169169        RETVAL=$?
     170        # Be careful: wait 1 second, making sure that everything is cleaned up.
     171        sleep 1
    170172        if ! pidof $binary > /dev/null 2>&1; then
    171173            rm -f $PIDFILE
  • trunk/src/VBox/Installer/solaris/smf-vboxwebsrv.sh

    r56299 r60532  
    125125        # Kill service contract
    126126        smf_kill_contract $2 TERM 1
     127        # Be careful: wait 1 second, making sure that everything is cleaned up.
     128        smf_kill_contract $2 TERM 1
    127129    ;;
    128130    *)
  • trunk/src/VBox/Main/webservice/vboxweb.cpp

    r60513 r60532  
    908908        g_pSoapQ = new SoapQ(&soap);
    909909
    910         for (uint64_t i = 1; g_fKeepRunning; i++)
    911         {
     910        uint64_t cAccepted = 1;
     911        while (g_fKeepRunning)
     912        {
     913            struct timeval timeout;
     914            fd_set fds;
     915            int rv;
     916            for (;;)
     917            {
     918                timeout.tv_sec = 60;
     919                timeout.tv_usec = 0;
     920                FD_ZERO(&fds);
     921                FD_SET(soap.master, &fds);
     922                rv = select((int)soap.master + 1, &fds, &fds, &fds, &timeout);
     923                if (rv > 0)
     924                    break; // work is waiting
     925                else if (rv == 0)
     926                    continue; // timeout, not necessary to bother gsoap
     927                else // r < 0, errno
     928                {
     929                    if (soap_socket_errno(soap.master) == SOAP_EINTR)
     930                        rv = 0; // re-check if we should terminate
     931                    break;
     932                }
     933            }
     934            if (rv == 0)
     935                continue;
     936
    912937            // call gSOAP to handle incoming SOAP connection
    913             soap.accept_timeout = 10;
     938            soap.accept_timeout = -1; // 1usec timeout, actual waiting is above
    914939            s = soap_accept(&soap);
    915940            if (!soap_valid_socket(s))
     
    923948            // pick up the job
    924949            size_t cItemsOnQ = g_pSoapQ->add(s);
    925             LogRel(("Request %llu on socket %d queued for processing (%d items on Q)\n", i, s, cItemsOnQ));
     950            LogRel(("Request %llu on socket %d queued for processing (%d items on Q)\n", cAccepted, s, cItemsOnQ));
     951            cAccepted++;
    926952        }
    927953
     
    13211347#else
    13221348    signal(SIGINT,   websrvSignalHandler);
     1349    signal(SIGTERM,  websrvSignalHandler);
    13231350# ifdef SIGBREAK
    13241351    signal(SIGBREAK, websrvSignalHandler);
     
    13461373#else
    13471374    signal(SIGINT,   SIG_DFL);
     1375    signal(SIGTERM,  SIG_DFL);
    13481376# ifdef SIGBREAK
    13491377    signal(SIGBREAK, SIG_DFL);
     
    13511379#endif
    13521380
     1381    RTThreadPoke(threadQPumper);
    13531382    RTThreadWait(threadQPumper, 30000, NULL);
    13541383    if (threadWatchdog != NIL_RTTHREAD)
     1384    {
     1385        RTThreadPoke(threadWatchdog);
    13551386        RTThreadWait(threadWatchdog, g_iWatchdogCheckInterval * 1000 + 10000, NULL);
     1387    }
    13561388
    13571389    /* VirtualBoxClient events unregistration. */
Note: See TracChangeset for help on using the changeset viewer.

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