MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / start

Function start

client/vglclient.cpp:355–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353
354
355int start(char *displayname)
356{
357 VGLTransReceiver *receiver = NULL;
358 Atom portAtom = None; unsigned short actualPort = 0;
359 bool newListener = false;
360 int retval = 0;
361
362 if(!XInitThreads()) { vglout.println("XInitThreads() failed"); return -1; }
363
364 signal(SIGINT, handler);
365 signal(SIGTERM, handler);
366 signal(SIGHUP, handler);
367 XSetErrorHandler(xhandler);
368
369 start:
370
371 try
372 {
373 restart = false;
374
375 if((maindpy = XOpenDisplay(displayname)) == NULL)
376 THROW("Could not open display");
377
378 if(!force) actualPort = instanceCheck(maindpy);
379 if(actualPort == 0)
380 {
381 receiver = new VGLTransReceiver(ipv6, drawMethod);
382 if(port == 0)
383 {
384 bool success = false; unsigned short i = RR_DEFAULTPORT;
385 do
386 {
387 try
388 {
389 receiver->listen(i);
390 success = true;
391 }
392 catch(...)
393 {
394 success = false; if(i == 0) throw;
395 }
396 i++;
397 if(i > 4299) i = 4200;
398 if(i == RR_DEFAULTPORT) i = 0;
399 } while(!success);
400 }
401 else receiver->listen(port);
402 vglout.println("Listening for connections on port %d%s",
403 actualPort = receiver->getPort(), ipv6 ? " [IPv6 enabled]" : "");
404 if((portAtom = XInternAtom(maindpy, "_VGLCLIENT_PORT", False)) == None)
405 THROW("Could not get _VGLCLIENT_PORT atom");
406 XChangeProperty(maindpy, RootWindow(maindpy, DefaultScreen(maindpy)),
407 portAtom, XA_INTEGER, 16, PropModeReplace,
408 (unsigned char *)&actualPort, 1);
409 newListener = true;
410 }
411
412 if(logFile && newListener)

Callers 1

mainFunction · 0.70

Calls 8

XOpenDisplayFunction · 0.85
instanceCheckFunction · 0.85
XCloseDisplayFunction · 0.85
printlnMethod · 0.80
getPortMethod · 0.80
logToMethod · 0.80
whatMethod · 0.80
listenMethod · 0.45

Tested by

no test coverage detected