Beispiel #1
0
/*
 *    waitforserver - wait for X server to start up
 */
static Bool
waitforserver(void)
{
    int    ncycles     = 120;        /* # of cycles to wait */
    int    cycles;            /* Wait cycle count */

#ifdef __APPLE__
    /* For Apple, we don't get signaled by the server when it's ready, so we just
     * want to sleep now since we're going to sleep later anyways and this allows us
     * to avoid the awkard, "why is there an error message in the log" questions
     * from users.
     */

    sleep(2);
#endif

    for (cycles = 0; cycles < ncycles; cycles++) {
        if ((xd = XOpenDisplay(displayNum))) {
            return(TRUE);
        }
        else {
            if (!processTimeout(1, "X server to begin accepting connections"))
              break;
        }
    }

    Errorx("giving up");

    return(FALSE);
}
Beispiel #2
0
void LogCollector::startTimeoutCheckTimer() {
    timeoutTimer_.start(uploadStrategy_->getTimeoutCheckPeriod(), [&]
                    {
                            if (isDeliveryTimeout()) {
                                processTimeout();
                            }
                            startTimeoutCheckTimer();
                    });
}
void CTimeoutManager::threadFunc()
{
   LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__);
   mpStartSemaphore->signal();

   while (mBe)
   {
      processTimeout();
      smartWait();
   }
}
QT_USE_NAMESPACE

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , transactionCount(0)
    , serialPortLabel(new QLabel(tr("Serial port:")))
    , serialPortComboBox(new QComboBox())
    , waitRequestLabel(new QLabel(tr("Wait request, msec:")))
    , waitRequestSpinBox(new QSpinBox())
    , responseLabel(new QLabel(tr("Response:")))
    , responseLineEdit(new QLineEdit(tr("Hello, I'm Slave.")))
    , trafficLabel(new QLabel(tr("No traffic.")))
    , statusLabel(new QLabel(tr("Status: Not running.")))
    , runButton(new QPushButton(tr("Start")))
{
    waitRequestSpinBox->setRange(0, 10000);
    waitRequestSpinBox->setValue(20);

    foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
        serialPortComboBox->addItem(info.portName());

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(serialPortLabel, 0, 0);
    mainLayout->addWidget(serialPortComboBox, 0, 1);
    mainLayout->addWidget(waitRequestLabel, 1, 0);
    mainLayout->addWidget(waitRequestSpinBox, 1, 1);
    mainLayout->addWidget(runButton, 0, 2, 2, 1);
    mainLayout->addWidget(responseLabel, 2, 0);
    mainLayout->addWidget(responseLineEdit, 2, 1, 1, 3);
    mainLayout->addWidget(trafficLabel, 3, 0, 1, 4);
    mainLayout->addWidget(statusLabel, 4, 0, 1, 5);
    setLayout(mainLayout);

    setWindowTitle(tr("Slave"));
    serialPortComboBox->setFocus();

    timer.setSingleShot(true);

    connect(runButton, SIGNAL(clicked()),
            this, SLOT(startSlave()));
    connect(&serial, SIGNAL(readyRead()),
            this, SLOT(readRequest()));
    connect(&timer, SIGNAL(timeout()),
            this, SLOT(processTimeout()));

    connect(serialPortComboBox, SIGNAL(currentIndexChanged(QString)),
            this, SLOT(activateRunButton()));
    connect(waitRequestSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(activateRunButton()));
    connect(responseLineEdit, SIGNAL(textChanged(QString)),
            this, SLOT(activateRunButton()));
}
Beispiel #5
0
static void
shutdown(void)
{
    /* have kept display opened, so close it now */
    if (clientpid > 0) {
        XSetIOErrorHandler(ignorexio);
        if (! setjmp(close_env)) {
            XCloseDisplay(xd);
        }

        /* HUP all local clients to allow them to clean up */
        if (killpg(clientpid, SIGHUP) < 0 && errno != ESRCH)
            Error("can't send HUP to process group %d", clientpid);
    }

    if (serverpid < 0)
        return;

    if (killpg(serverpid, SIGTERM) < 0) {
        if (errno == ESRCH)
            return;
        Fatal("can't kill X server");
    }

    if (!processTimeout(10, "X server to shut down"))
        return;

    Errorx("X server slow to shut down, sending KILL signal");

    if (killpg(serverpid, SIGKILL) < 0) {
        if (errno == ESRCH)
            return;
        Error("can't SIGKILL X server");
    }

    if (processTimeout(3, "server to die"))
        Fatalx("X server refuses to die");
}
Beispiel #6
0
	/**
		tick
	*/
	void tick()
	{
		if(timestamp() - lastTimestamp_ < (ServerConfig::getSingleton().callback_timeout_ * stampsPerSecond()))
			return;

		lastTimestamp_ = timestamp(); 
		typename CALLBACKS::iterator iter = cbMap_.begin();
		for(; iter!= cbMap_.end(); )
		{
			if(lastTimestamp_ > iter->second.second)
			{
				if(processTimeout(iter->first, iter->second.first))
				{
					idAlloc_.reclaim(iter->first);
					cbMap_.erase(iter++);
					continue;
				}
			}

			++iter;
		}
	}
Beispiel #7
0
void NanoNet::poll(){
	NanoSocket *sck;
	uint8_t lport;
	uint8_t rport;
	uint8_t dataLength;
	uint8_t *data;
	uint8_t *raddr;
	bool handled = false;

	NanoInterface *intf = primaryIf;

	uint8_t *packet = NULL;

	/* Process ack / errors */ 

	sck = sock;

	while(sck){
		if(sck->state && sck->timeout && sck->handler){
			processSocketState(sck);
		}
		sck = sck->next;
	}


	while(intf){
		while(intf->available() >= NANO_PACKET_SIZE){

			packet = intf->recv(NANO_PACKET_SIZE);

			handlePacket(intf,packet);
		}

		intf = intf->next;
	}

	processTimeout();
}
Beispiel #8
0
static int
startServer(char *server[])
{
    sigset_t mask, old;
    const char * const *cpp;

    sigemptyset(&mask);
    sigaddset(&mask, SIGUSR1);
    sigprocmask(SIG_BLOCK, &mask, &old);

    serverpid = fork();

    switch(serverpid) {
    case 0:
        /* Unblock */
        sigprocmask(SIG_SETMASK, &old, NULL);

        /*
         * don't hang on read/write to control tty
         */
        signal(SIGTTIN, SIG_IGN);
        signal(SIGTTOU, SIG_IGN);
        /*
         * ignore SIGUSR1 in child.  The server
         * will notice this and send SIGUSR1 back
         * at xinit when ready to accept connections
         */
        signal(SIGUSR1, SIG_IGN);
        /*
         * prevent server from getting sighup from vhangup()
         * if client is xterm -L
         */
        setpgid(0,getpid());
        Execute(server);

        Error("unable to run server \"%s\"", server[0]);

        fprintf(stderr, "Use the -- option, or make sure that %s is in your path and\n", bindir);
        fprintf(stderr, "that \"%s\" is a program or a link to the right type of server\n", server[0]);
        fprintf(stderr, "for your display.  Possible server names include:\n\n");
        for (cpp = server_names; *cpp; cpp++)
            fprintf(stderr, "    %s\n", *cpp);
        fprintf(stderr, "\n");

        exit(EXIT_FAILURE);

        break;
    case -1:
        break;
    default:
        /*
         * don't nice server
         */
        setpriority(PRIO_PROCESS, serverpid, -1);

        errno = 0;
        if(! processTimeout(0, "")) {
            serverpid = -1;
            break;
        }
        /*
         * kludge to avoid race with TCP, giving server time to
         * set his socket options before we try to open it,
         * either use the 15 second timeout, or await SIGUSR1.
         *
         * If your machine is substantially slower than 15 seconds,
         * you can easily adjust this value.
         */
        alarm(15);

        sigsuspend(&old);
        alarm(0);
        sigprocmask(SIG_SETMASK, &old, NULL);

        if (waitforserver() == 0) {
            Error("unable to connect to X server");
            shutdown();
            serverpid = -1;
        }
        break;
    }

    return(serverpid);
}