- Timestamp:
- Oct 11, 2010 4:30:54 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 66568
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r32741 r33044 483 483 { 484 484 /* Get the path to the executable. */ 485 char path 486 RTPathAppPrivateArch 487 size_t sz = strlen 488 path 489 path 485 char path[RTPATH_MAX]; 486 RTPathAppPrivateArch(path, RTPATH_MAX); 487 size_t sz = strlen(path); 488 path[sz++] = RTPATH_DELIMITER; 489 path[sz] = 0; 490 490 char *cmd = path + sz; 491 491 sz = RTPATH_MAX - sz; 492 492 493 493 int rc = 0; 494 RTPROCESS pid = NIL_RTPROCESS;495 RTENV env = RTENV_DEFAULT;496 497 494 const char VirtualBox_exe[] = "VirtualBox" HOSTSUFF_EXE; 498 Assert (sz >= sizeof(VirtualBox_exe));499 strcpy 495 Assert(sz >= sizeof(VirtualBox_exe)); 496 strcpy(cmd, VirtualBox_exe); 500 497 const char * args[] = {path, 0 }; 501 # ifdef RT_OS_WINDOWS 502 rc = RTProcCreate (path, args, env, 0, &pid); 503 # else 504 rc = RTProcCreate (path, args, env, RTPROC_FLAGS_DAEMONIZE_DEPRECATED, &pid); 505 # endif 506 if (RT_FAILURE (rc)) 498 rc = RTProcCreate(path, args, RTENV_DEFAULT, RTPROC_FLAGS_DETACHED, NULL); 499 if (RT_FAILURE(rc)) 507 500 LogRel(("Systray: Failed to start new selector window! Path=%s, rc=%Rrc\n", path, rc)); 508 501 } … … 515 508 { 516 509 int rc = 0; 517 QString strTrayWinID = mVBox.GetExtraData 510 QString strTrayWinID = mVBox.GetExtraData(VBoxDefs::GUI_TrayIconWinID); 518 511 if (false == strTrayWinID.isEmpty()) 519 512 { 520 513 /* Check if current tray icon is alive by writing some bogus value. */ 521 mVBox.SetExtraData 514 mVBox.SetExtraData(VBoxDefs::GUI_TrayIconWinID, "0"); 522 515 if (mVBox.isOk()) 523 516 { 524 517 /* Current tray icon died - clean up. */ 525 mVBox.SetExtraData 518 mVBox.SetExtraData(VBoxDefs::GUI_TrayIconWinID, NULL); 526 519 strTrayWinID.clear(); 527 520 } … … 535 528 { 536 529 /* Get the path to the executable. */ 537 char path 538 RTPathAppPrivateArch 539 size_t sz = strlen 540 path 541 path 530 char path[RTPATH_MAX]; 531 RTPathAppPrivateArch(path, RTPATH_MAX); 532 size_t sz = strlen(path); 533 path[sz++] = RTPATH_DELIMITER; 534 path[sz] = 0; 542 535 char *cmd = path + sz; 543 536 sz = RTPATH_MAX - sz; 544 537 545 RTPROCESS pid = NIL_RTPROCESS;546 RTENV env = RTENV_DEFAULT;547 548 538 const char VirtualBox_exe[] = "VirtualBox" HOSTSUFF_EXE; 549 Assert (sz >= sizeof(VirtualBox_exe));550 strcpy 539 Assert(sz >= sizeof(VirtualBox_exe)); 540 strcpy(cmd, VirtualBox_exe); 551 541 const char * args[] = {path, "-systray", 0 }; 552 # ifdef RT_OS_WINDOWS /** @todo drop this once the RTProcCreate bug has been fixed */ 553 rc = RTProcCreate (path, args, env, 0, &pid); 554 # else 555 rc = RTProcCreate (path, args, env, RTPROC_FLAGS_DAEMONIZE_DEPRECATED, &pid); 556 # endif 557 558 if (RT_FAILURE (rc)) 542 rc = RTProcCreate(path, args, RTENV_DEFAULT, RTPROC_FLAGS_DETACHED, NULL); 543 if (RT_FAILURE(rc)) 559 544 { 560 545 LogRel(("Systray: Failed to start systray window! Path=%s, rc=%Rrc\n", path, rc)); … … 566 551 { 567 552 // Use this selector for displaying the tray icon 568 mVBox.SetExtraData 569 QString ("%1").arg ((qulonglong)vboxGlobal().mainWindow()->winId()));553 mVBox.SetExtraData(VBoxDefs::GUI_TrayIconWinID, 554 QString("%1").arg((qulonglong)vboxGlobal().mainWindow()->winId())); 570 555 571 556 /* The first process which can grab this "mutex" will win -> … … 4935 4920 /** 4936 4921 * Initialize a debugger config variable. 4937 * 4922 * 4938 4923 * @param piDbgCfgVar The debugger config variable to init. 4939 * @param pszEnvVar The environment variable name relating to this 4924 * @param pszEnvVar The environment variable name relating to this 4940 4925 * variable. 4941 4926 * @param pszExtraDataName The extra data name relating to this variable. … … 4964 4949 else if (strEnvValue.isNull() && strExtraValue.isNull()) 4965 4950 *piDbgCfgVar = fDefault ? VBOXGLOBAL_DBG_CFG_VAR_TRUE : VBOXGLOBAL_DBG_CFG_VAR_FALSE; 4966 else 4951 else 4967 4952 { 4968 4953 QString *pStr = !strEnvValue.isEmpty() ? &strEnvValue : &strExtraValue; … … 4980 4965 || pStr->toLongLong() == 0) 4981 4966 *piDbgCfgVar = VBOXGLOBAL_DBG_CFG_VAR_FALSE; 4982 else 4967 else 4983 4968 { 4984 4969 LogFunc(("Ignoring unknown value '%s' for '%s'\n", pStr->toAscii().constData(), pStr == &strEnvValue ? pszEnvVar : pszExtraDataName)); … … 4988 4973 } 4989 4974 4990 /** 4991 * Set a debugger config variable according according to start up argument. 4992 * 4993 * @param piDbgCfgVar The debugger config variable to set. 4994 * @param fState The value from the command line. 4995 */ 4975 /** 4976 * Set a debugger config variable according according to start up argument. 4977 * 4978 * @param piDbgCfgVar The debugger config variable to set. 4979 * @param fState The value from the command line. 4980 */ 4996 4981 void VBoxGlobal::setDebuggerVar(int *piDbgCfgVar, bool fState) 4997 4982 { 4998 4983 if (!(*piDbgCfgVar & VBOXGLOBAL_DBG_CFG_VAR_DONE)) 4999 *piDbgCfgVar = (fState ? VBOXGLOBAL_DBG_CFG_VAR_TRUE : VBOXGLOBAL_DBG_CFG_VAR_FALSE) 4984 *piDbgCfgVar = (fState ? VBOXGLOBAL_DBG_CFG_VAR_TRUE : VBOXGLOBAL_DBG_CFG_VAR_FALSE) 5000 4985 | VBOXGLOBAL_DBG_CFG_VAR_CMD_LINE; 5001 4986 } 5002 4987 5003 4988 /** 5004 * Checks the state of a debugger config variable, updating it with the machine 5005 * settings on the first invocation. 5006 * 4989 * Checks the state of a debugger config variable, updating it with the machine 4990 * settings on the first invocation. 4991 * 5007 4992 * @returns true / false. 5008 4993 * @param piDbgCfgVar The debugger config variable to consult. -
trunk/src/VBox/Main/xpcom/server.cpp
r31872 r33044 1072 1072 /* now we're ready, signal the parent process */ 1073 1073 write(daemon_pipe_wr, "READY", strlen("READY")); 1074 /* close writing end of the pipe, its job is done */ 1075 close(daemon_pipe_wr); 1074 1076 } 1075 1077 else … … 1150 1152 RTFileDelete(g_pszPidFile); 1151 1153 1152 /* close writing end of the pipe as well */1153 if (daemon_pipe_wr >= 0)1154 close(daemon_pipe_wr);1155 1156 1154 return 0; 1157 1155 } -
trunk/src/VBox/Runtime/r3/posix/process-posix.cpp
r33009 r33044 266 266 AssertPtrReturn(pszExec, VERR_INVALID_POINTER); 267 267 AssertReturn(*pszExec, VERR_INVALID_PARAMETER); 268 AssertReturn(!(fFlags & ~(RTPROC_FLAGS_D AEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER);268 AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER); 269 269 AssertReturn(!(fFlags & RTPROC_FLAGS_DETACHED) || !phProcess, VERR_INVALID_PARAMETER); 270 270 AssertReturn(hEnv != NIL_RTENV, VERR_INVALID_PARAMETER); … … 346 346 } 347 347 348 /* 349 * Spawn the child. 348 pid_t pid = -1; 349 350 /* 351 * Take care of detaching the process. 350 352 * 351 353 * HACK ALERT! Put the process into a new process group with pgid = pid 352 354 * to make sure it differs from that of the parent process to ensure that 353 * the IPRT waipit call doesn't race anyone (read XPCOM) doing group wide 354 * waits. 355 */ 356 pid_t pid = -1; 355 * the IPRT waitpid call doesn't race anyone (read XPCOM) doing group wide 356 * waits. setsid() includes the setpgid() functionality. 357 * 2010-10-11 XPCOM no longer waits for anything, but it cannot hurt. 358 */ 359 #ifndef RT_OS_OS2 360 if (fFlags & RTPROC_FLAGS_DETACHED) 361 { 362 # ifdef RT_OS_SOLARIS 363 int templateFd = rtSolarisContractPreFork(); 364 if (templateFd == -1) 365 return VERR_OPEN_FAILED; 366 # endif /* RT_OS_SOLARIS */ 367 pid = fork(); 368 if (!pid) 369 { 370 # ifdef RT_OS_SOLARIS 371 rtSolarisContractPostForkChild(templateFd); 372 # endif /* RT_OS_SOLARIS */ 373 setsid(); /* see comment above */ 374 375 pid = -1; 376 /* Child falls through to the actual spawn code below. */ 377 } 378 else 379 { 380 #ifdef RT_OS_SOLARIS 381 rtSolarisContractPostForkParent(templateFd, pid); 382 #endif /* RT_OS_SOLARIS */ 383 if (pid > 0) 384 { 385 /* Must wait for the temporary process to avoid a zombie. */ 386 int status; 387 waitpid(pid, &status, 0); 388 /* Assume that something wasn't found. No detailed info. */ 389 if (status) 390 return VERR_PROCESS_NOT_FOUND; 391 if (phProcess) 392 *phProcess = 0; 393 return VINF_SUCCESS; 394 } 395 return RTErrConvertFromErrno(errno); 396 } 397 } 398 #endif 399 400 /* 401 * Spawn the child. 402 * 403 * Any spawn code MUST not execute any atexit functions if it is for a 404 * detached process. It would lead to running the atexit functions which 405 * make only sense for the parent. libORBit e.g. gets confused by multiple 406 * execution. Remember, there was only a fork() so far, and until exec() 407 * is successfully run there is nothing which would prevent doing anything 408 * silly with the (duplicated) file descriptors. 409 */ 357 410 #ifdef HAVE_POSIX_SPAWN 358 411 /** @todo OS/2: implement DETACHED (BACKGROUND stuff), see VbglR3Daemonize. */ 359 /** @todo Try do the detach thing with posix spawn. */ 360 if ( !(fFlags & (RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED)) 361 && uid == ~(uid_t)0 362 && gid == ~(gid_t)0 363 ) 412 if ( uid == ~(uid_t)0 413 && gid == ~(gid_t)0) 364 414 { 365 415 /* Spawn attributes. */ … … 428 478 if (!rc) 429 479 { 480 /* For a detached process this happens in the temp process, so 481 * it's not worth doing anything as this process must exit. */ 482 if (fFlags & RTPROC_FLAGS_DETACHED) 483 _Exit(0); 430 484 if (phProcess) 431 485 *phProcess = pid; … … 433 487 } 434 488 } 489 /* For a detached process this happens in the temp process, so 490 * it's not worth doing anything as this process must exit. */ 491 if (fFlags & RTPROC_FLAGS_DETACHED) 492 _Exit(124); 435 493 } 436 494 else … … 448 506 rtSolarisContractPostForkChild(templateFd); 449 507 #endif /* RT_OS_SOLARIS */ 450 setpgid(0, 0); /* see comment above */ 508 if (!(fFlags & RTPROC_FLAGS_DETACHED)) 509 setpgid(0, 0); /* see comment above */ 451 510 452 511 /* … … 457 516 { 458 517 if (setgid(gid)) 459 exit(126); 518 { 519 if (fFlags & RTPROC_FLAGS_DETACHED) 520 _Exit(126); 521 else 522 exit(126); 523 } 460 524 } 461 525 … … 463 527 { 464 528 if (setuid(uid)) 465 exit(126); 529 { 530 if (fFlags & RTPROC_FLAGS_DETACHED) 531 _Exit(126); 532 else 533 exit(126); 534 } 466 535 } 467 536 #endif … … 479 548 int rc2 = dup2(fd, i); 480 549 if (rc2 != i) 481 exit(125); 550 { 551 if (fFlags & RTPROC_FLAGS_DETACHED) 552 _Exit(125); 553 else 554 exit(125); 555 } 482 556 for (int j = i + 1; j < 3; j++) 483 557 if (aStdFds[j] == fd) … … 492 566 493 567 /* 494 * Daemonize the process if requested.495 */496 if (fFlags & (RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED))497 {498 rc = RTProcDaemonizeUsingFork(true /*fNoChDir*/,499 !(fFlags & RTPROC_FLAGS_DAEMONIZE_DEPRECATED) /*fNoClose*/,500 NULL /* pszPidFile */);501 if (RT_FAILURE(rc))502 {503 /* parent */504 AssertReleaseMsgFailed(("RTProcDaemonize returns %Rrc errno=%d\n", rc, errno));505 exit(127);506 }507 /* daemonized child */508 }509 510 /*511 568 * Finally, execute the requested program. 512 569 */ … … 520 577 RTAssertMsg2Weak("execve returns %d errno=%d\n", rc, errno); 521 578 RTAssertReleasePanic(); 522 exit(127); 579 if (fFlags & RTPROC_FLAGS_DETACHED) 580 _Exit(127); 581 else 582 exit(127); 523 583 } 524 584 #ifdef RT_OS_SOLARIS … … 527 587 if (pid > 0) 528 588 { 589 /* For a detached process this happens in the temp process, so 590 * it's not worth doing anything as this process must exit. */ 591 if (fFlags & RTPROC_FLAGS_DETACHED) 592 _Exit(0); 529 593 if (phProcess) 530 594 *phProcess = pid; 531 else if (fFlags & (RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED))532 {533 /* If the process is detached straight away wait for the534 * intermediate process to exit (it should do that quickly)535 * if the caller didn't want to know the PID. If it wants the536 * PID it's his job to wait for it or he gets a zombie. */537 waitpid(pid, NULL, 0);538 }539 595 return VINF_SUCCESS; 540 596 } 541 rc = errno; 542 } 543 597 /* For a detached process this happens in the temp process, so 598 * it's not worth doing anything as this process must exit. */ 599 if (fFlags & RTPROC_FLAGS_DETACHED) 600 _Exit(124); 601 return RTErrConvertFromErrno(errno); 602 } 544 603 545 604 return VERR_NOT_IMPLEMENTED; -
trunk/src/VBox/Runtime/r3/win/process-win.cpp
r32657 r33044 941 941 AssertPtrReturn(pszExec, VERR_INVALID_POINTER); 942 942 AssertReturn(*pszExec, VERR_INVALID_PARAMETER); 943 AssertReturn(!(fFlags & ~(RTPROC_FLAGS_D AEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER);943 AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER); 944 944 AssertReturn(!(fFlags & RTPROC_FLAGS_DETACHED) || !phProcess, VERR_INVALID_PARAMETER); 945 945 AssertReturn(hEnv != NIL_RTENV, VERR_INVALID_PARAMETER); -
trunk/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp
r30514 r33044 1216 1216 PRProcessAttr *attr = nsnull; 1217 1217 nsresult rv = NS_ERROR_FAILURE; 1218 PRFileDesc *devNull; 1218 1219 char *const argv[] = { (char *const) path, nsnull }; 1219 1220 char c; … … 1233 1234 1234 1235 if (PR_ProcessAttrSetInheritableFD(attr, writable, IPC_STARTUP_PIPE_NAME) != PR_SUCCESS) 1236 goto end; 1237 1238 devNull = PR_Open("/dev/null", PR_RDWR, 0); 1239 if (!devNull) 1235 1240 goto end; 1241 1242 PR_ProcessAttrSetStdioRedirect(attr, PR_StandardInput, devNull); 1243 PR_ProcessAttrSetStdioRedirect(attr, PR_StandardOutput, devNull); 1244 PR_ProcessAttrSetStdioRedirect(attr, PR_StandardError, devNull); 1236 1245 1237 1246 if (PR_CreateProcessDetached(path, argv, nsnull, attr) != PR_SUCCESS) 1238 1247 goto end; 1239 1248 1249 // Close /dev/null 1250 PR_Close(devNull); 1240 1251 // close the child end of the pipe in order to get notification on unexpected 1241 1252 // child termination instead of being infinitely blocked in PR_Read(). -
trunk/src/libs/xpcom18a4/ipc/ipcd/daemon/src/ipcdUnix.cpp
r20282 r33044 50 50 #endif 51 51 52 #ifdef VBOX 53 # include <iprt/initterm.h> 54 #endif 55 52 56 #include "prio.h" 53 57 #include "prerror.h" … … 467 471 PRFileDesc *listenFD = NULL; 468 472 PRNetAddr addr; 473 474 #ifdef VBOX 475 /* Set up the runtime without loading the support driver. */ 476 RTR3Init(); 477 #endif 469 478 470 479 // … … 537 546 } 538 547 else { 548 #ifndef VBOX 539 549 // redirect all standard file descriptors to /dev/null for 540 550 // proper daemonizing … … 545 555 PR_Close(PR_STDERR); 546 556 PR_Open("/dev/null", O_WRONLY, 0); 557 #endif 547 558 548 559 IPC_NotifyParent(); -
trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/uxproces.c
r32971 r33044 467 467 const PRProcessAttr *attr) 468 468 { 469 #ifdef VBOX 470 /* 2010-10-11 Block this for good. */ 471 return NULL; 472 #endif 469 473 struct pr_CreateProcOp *op; 470 474 PRProcess *proc; … … 529 533 const PRProcessAttr *attr) 530 534 { 535 #ifdef VBOX 536 /* 2010-10-11 Block this for good. */ 537 return NULL; 538 #endif 531 539 if (PR_CallOnce(&pr_wp.once, _MD_InitProcesses) == PR_FAILURE) { 532 540 return NULL; … … 550 558 RTENV newEnv = RTENV_DEFAULT; 551 559 552 if (PR_CallOnce(&pr_wp.once, _MD_InitProcesses) == PR_FAILURE) {553 return PR_FAILURE;554 }555 560 /* this code doesn't support all attributes */ 556 561 PR_ASSERT(!attr || !attr->currentDirectory); 557 PR_ASSERT(!attr || !attr->stdinFd);558 PR_ASSERT(!attr || !attr->stdoutFd);559 PR_ASSERT(!attr || !attr->stderrFd);560 562 /* no custom environment, please */ 561 563 PR_ASSERT(!envp); … … 575 577 } 576 578 577 vrc = RTProcCreate(path, (const char **)argv, childEnv, 578 RTPROC_FLAGS_DETACHED, NULL); 579 PRTHANDLE pStdIn = NULL, pStdOut = NULL, pStdErr = NULL; 580 RTHANDLE hStdIn, hStdOut, hStdErr; 581 if (attr && attr->stdinFd) 582 { 583 hStdIn.enmType = RTHANDLETYPE_FILE; 584 RTFileFromNative(&hStdIn.u.hFile, attr->stdinFd->secret->md.osfd); 585 pStdIn = &hStdIn; 586 } 587 if (attr && attr->stdoutFd) 588 { 589 hStdOut.enmType = RTHANDLETYPE_FILE; 590 RTFileFromNative(&hStdOut.u.hFile, attr->stdoutFd->secret->md.osfd); 591 pStdOut = &hStdOut; 592 } 593 if (attr && attr->stderrFd) 594 { 595 hStdErr.enmType = RTHANDLETYPE_FILE; 596 RTFileFromNative(&hStdErr.u.hFile, attr->stderrFd->secret->md.osfd); 597 pStdErr = &hStdErr; 598 } 599 600 vrc = RTProcCreateEx(path, (const char **)argv, childEnv, 601 RTPROC_FLAGS_DETACHED, pStdIn, pStdOut, pStdErr, 602 NULL /* pszAsUser */, NULL /* pszPassword */, 603 NULL /* phProcess */); 579 604 if (newEnv != RTENV_DEFAULT) { 580 605 RTEnvDestroy(newEnv); … … 686 711 * to port the NSPR to use IPRT, as currently this races with getting 687 712 * the exit code, but that's pretty harmless. */ 688 /** @todo fix this properly, by using IPRT for process management */ 713 /* Since 2010-10-11 this code cannot be reached as IPRT took over 714 * what we need, and the rest is blocked. */ 689 715 if (_PR_PID_REAPED == pRec->state) { 690 716 DeletePidTable(pRec); … … 735 761 * to ensure we do not interfere with RT 736 762 */ 763 /* Since 2010-10-11 this code cannot be reached as IPRT took over 764 * what we need, and the rest is blocked. */ 737 765 pid = waitpid((pid_t) 0, &status, 0); 738 766 #else … … 833 861 * to ensure we do not interfere with RT 834 862 */ 863 /* Since 2010-10-11 this code cannot be reached as IPRT took over 864 * what we need, and the rest is blocked. */ 835 865 pid = waitpid((pid_t) 0, &status, WNOHANG); 836 866 #else -
trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptio.c
r11780 r33044 336 336 * For sendfile() 337 337 */ 338 struct file_spec { 338 struct file_spec { 339 339 off_t offset; /* offset in file to send */ 340 340 size_t nbytes; /* length of file data to send */ … … 353 353 int nbytes_to_send; /* size of header and file */ 354 354 #endif /* HPUX11 */ 355 355 356 356 #ifdef SOLARIS 357 357 /* … … 369 369 size_t count; 370 370 #endif /* LINUX */ 371 371 372 372 PRIntervalTime timeout; /* client (relative) timeout */ 373 373 … … 402 402 LL_I2L(aMil, 1000000); 403 403 LL_DIV(elapsed, elapsed, aMil); 404 404 405 405 if (NULL != msg) PR_fprintf(debug_out, "%s", msg); 406 406 PR_fprintf( … … 444 444 PRBool wait_for_remaining; 445 445 PRThread *self = PR_GetCurrentThread(); 446 446 447 447 PR_ASSERT(PR_INTERVAL_NO_WAIT != op->timeout); 448 448 PR_ASSERT(op->arg1.osfd < FD_SETSIZE); … … 491 491 if ((op->event & POLLOUT) && FD_ISSET(op->arg1.osfd, &wr)) 492 492 revents |= POLLOUT; 493 493 494 494 if (op->function(op, revents)) 495 495 op->status = pt_continuation_done; … … 548 548 if ((op->event & POLLOUT) && FD_ISSET(op->arg1.osfd, &wr)) 549 549 revents |= POLLOUT; 550 550 551 551 if (op->function(op, revents)) 552 552 op->status = pt_continuation_done; … … 587 587 PRBool wait_for_remaining; 588 588 PRThread *self = PR_GetCurrentThread(); 589 589 590 590 PR_ASSERT(PR_INTERVAL_NO_WAIT != op->timeout); 591 591 #if defined (_PR_POLL_WITH_SELECT) … … 612 612 613 613 rv = poll(&tmp_pfd, 1, msecs); 614 614 615 615 if (self->state & PT_THREAD_ABORTED) 616 616 { … … 670 670 } 671 671 rv = poll(&tmp_pfd, 1, msecs); 672 672 673 673 if (self->state & PT_THREAD_ABORTED) 674 674 { … … 686 686 687 687 if ((revents & POLLNVAL) /* busted in all cases */ 688 || ((events & POLLOUT) && (revents & POLLHUP))) 688 || ((events & POLLOUT) && (revents & POLLHUP))) 689 689 /* write op & hup */ 690 690 { … … 777 777 op->arg1.osfd, op->arg2.buffer, op->arg3.amount); 778 778 op->syserrno = errno; 779 return ((-1 == op->result.code) && 779 return ((-1 == op->result.code) && 780 780 (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno)) ? 781 781 PR_FALSE : PR_TRUE; … … 801 801 #endif 802 802 op->syserrno = errno; 803 return ((-1 == op->result.code) && 803 return ((-1 == op->result.code) && 804 804 (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno)) ? 805 805 PR_FALSE : PR_TRUE; … … 961 961 op->arg4.flags, (struct sockaddr*)op->arg5.addr, &addr_len); 962 962 op->syserrno = errno; 963 return ((-1 == op->result.code) && 963 return ((-1 == op->result.code) && 964 964 (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno)) ? 965 965 PR_FALSE : PR_TRUE; … … 1069 1069 #endif /* HPUX11 */ 1070 1070 1071 #ifdef SOLARIS 1071 #ifdef SOLARIS 1072 1072 static PRBool pt_solaris_sendfile_cont(pt_Continuation *op, PRInt16 revents) 1073 1073 { … … 1089 1089 } 1090 1090 PR_ASSERT(count <= op->nbytes_to_send); 1091 1091 1092 1092 op->result.code += count; 1093 1093 if (count < op->nbytes_to_send) { … … 1113 1113 #endif /* SOLARIS */ 1114 1114 1115 #ifdef LINUX 1115 #ifdef LINUX 1116 1116 static PRBool pt_linux_sendfile_cont(pt_Continuation *op, PRInt16 revents) 1117 1117 { … … 1152 1152 PR_ASSERT(NULL != _pr_flock_cv); 1153 1153 _pr_rename_lock = PR_NewLock(); 1154 PR_ASSERT(NULL != _pr_rename_lock); 1155 1156 _PR_InitFdCache(); /* do that */ 1154 PR_ASSERT(NULL != _pr_rename_lock); 1155 1156 _PR_InitFdCache(); /* do that */ 1157 1157 1158 1158 _pr_stdin = pt_SetMethods(0, PR_DESC_FILE, PR_FALSE, PR_TRUE); … … 1189 1189 _PR_Putfd(_pr_stdout); 1190 1190 _pr_stdout = NULL; 1191 _PR_Putfd(_pr_stderr); 1191 _PR_Putfd(_pr_stderr); 1192 1192 _pr_stderr = NULL; 1193 1193 1194 1194 _PR_CleanupFdCache(); 1195 1195 1196 1196 if (_pr_flock_cv) 1197 1197 { … … 1217 1217 1218 1218 if (!_pr_initialized) _PR_ImplicitInitialization(); 1219 1219 1220 1220 switch (osfd) 1221 1221 { … … 2126 2126 } 2127 2127 2128 /* 2128 /* 2129 2129 * pt_AIXDispatchSendFile 2130 2130 */ … … 2150 2150 * 2151 2151 * Send file sfd->fd across socket sd. If specified, header and trailer 2152 * buffers are sent before and after the file, respectively. 2152 * buffers are sent before and after the file, respectively. 2153 2153 * 2154 2154 * PR_TRANSMITFILE_CLOSE_SOCKET flag - close socket after sending file 2155 * 2155 * 2156 2156 * return number of bytes sent or -1 on error 2157 2157 * … … 2160 2160 */ 2161 2161 2162 static PRInt32 pt_AIXSendFile(PRFileDesc *sd, PRSendFileData *sfd, 2162 static PRInt32 pt_AIXSendFile(PRFileDesc *sd, PRSendFileData *sfd, 2163 2163 PRTransmitFileFlags flags, PRIntervalTime timeout) 2164 2164 { … … 2250 2250 * 2251 2251 * PR_TRANSMITFILE_CLOSE_SOCKET flag - close socket after sending file 2252 * 2252 * 2253 2253 * return number of bytes sent or -1 on error 2254 2254 * … … 2257 2257 */ 2258 2258 2259 static PRInt32 pt_HPUXSendFile(PRFileDesc *sd, PRSendFileData *sfd, 2259 static PRInt32 pt_HPUXSendFile(PRFileDesc *sd, PRSendFileData *sfd, 2260 2260 PRTransmitFileFlags flags, PRIntervalTime timeout) 2261 2261 { … … 2272 2272 _PR_MD_MAP_FSTAT_ERROR(errno); 2273 2273 return -1; 2274 } 2274 } 2275 2275 file_nbytes_to_send = statbuf.st_size - sfd->file_offset; 2276 2276 } else { … … 2363 2363 #endif /* HPUX11 */ 2364 2364 2365 #ifdef SOLARIS 2365 #ifdef SOLARIS 2366 2366 2367 2367 /* … … 2383 2383 { 2384 2384 struct stat statbuf; 2385 size_t nbytes_to_send, file_nbytes_to_send; 2386 struct sendfilevec sfv_struct[3]; 2387 int sfvcnt = 0; 2385 size_t nbytes_to_send, file_nbytes_to_send; 2386 struct sendfilevec sfv_struct[3]; 2387 int sfvcnt = 0; 2388 2388 size_t xferred; 2389 2389 PRInt32 count; … … 2395 2395 _PR_MD_MAP_FSTAT_ERROR(errno); 2396 2396 return -1; 2397 } 2397 } 2398 2398 file_nbytes_to_send = statbuf.st_size - sfd->file_offset; 2399 2399 } else { … … 2406 2406 sfv_struct[sfvcnt].sfv_fd = SFV_FD_SELF; 2407 2407 sfv_struct[sfvcnt].sfv_flag = 0; 2408 sfv_struct[sfvcnt].sfv_off = (off_t) sfd->header; 2408 sfv_struct[sfvcnt].sfv_off = (off_t) sfd->header; 2409 2409 sfv_struct[sfvcnt].sfv_len = sfd->hlen; 2410 2410 sfvcnt++; … … 2422 2422 sfv_struct[sfvcnt].sfv_fd = SFV_FD_SELF; 2423 2423 sfv_struct[sfvcnt].sfv_flag = 0; 2424 sfv_struct[sfvcnt].sfv_off = (off_t) sfd->trailer; 2424 sfv_struct[sfvcnt].sfv_off = (off_t) sfd->trailer; 2425 2425 sfv_struct[sfvcnt].sfv_len = sfd->tlen; 2426 2426 sfvcnt++; … … 2431 2431 goto done; 2432 2432 } 2433 2433 2434 2434 /* 2435 2435 * Strictly speaking, we may have sent some bytes when the … … 2498 2498 void *handle; 2499 2499 PRBool close_it = PR_FALSE; 2500 2500 2501 2501 /* 2502 2502 * We do not want to unload libsendfile.so. This handle is leaked … … 2521 2521 PR_LOG(_pr_io_lm, PR_LOG_DEBUG, 2522 2522 ("dlsym(sendfilev) returns %p", pt_solaris_sendfilev_fptr)); 2523 2523 2524 2524 if (close_it) { 2525 2525 dlclose(handle); … … 2527 2527 } 2528 2528 2529 /* 2529 /* 2530 2530 * pt_SolarisDispatchSendFile 2531 2531 */ … … 2556 2556 * 2557 2557 * PR_TRANSMITFILE_CLOSE_SOCKET flag - close socket after sending file 2558 * 2558 * 2559 2559 * return number of bytes sent or -1 on error 2560 2560 * … … 2567 2567 { 2568 2568 struct stat statbuf; 2569 size_t file_nbytes_to_send; 2569 size_t file_nbytes_to_send; 2570 2570 PRInt32 count = 0; 2571 2571 ssize_t rv; … … 2580 2580 _PR_MD_MAP_FSTAT_ERROR(errno); 2581 2581 return -1; 2582 } 2582 } 2583 2583 file_nbytes_to_send = statbuf.st_size - sfd->file_offset; 2584 2584 } else { … … 3075 3075 pt_FileInfo, 3076 3076 pt_FileInfo64, 3077 (PRWritevFN)_PR_InvalidInt, 3078 (PRConnectFN)_PR_InvalidStatus, 3079 (PRAcceptFN)_PR_InvalidDesc, 3080 (PRBindFN)_PR_InvalidStatus, 3081 (PRListenFN)_PR_InvalidStatus, 3082 (PRShutdownFN)_PR_InvalidStatus, 3083 (PRRecvFN)_PR_InvalidInt, 3084 (PRSendFN)_PR_InvalidInt, 3085 (PRRecvfromFN)_PR_InvalidInt, 3086 (PRSendtoFN)_PR_InvalidInt, 3077 (PRWritevFN)_PR_InvalidInt, 3078 (PRConnectFN)_PR_InvalidStatus, 3079 (PRAcceptFN)_PR_InvalidDesc, 3080 (PRBindFN)_PR_InvalidStatus, 3081 (PRListenFN)_PR_InvalidStatus, 3082 (PRShutdownFN)_PR_InvalidStatus, 3083 (PRRecvFN)_PR_InvalidInt, 3084 (PRSendFN)_PR_InvalidInt, 3085 (PRRecvfromFN)_PR_InvalidInt, 3086 (PRSendtoFN)_PR_InvalidInt, 3087 3087 pt_Poll, 3088 (PRAcceptreadFN)_PR_InvalidInt, 3089 (PRTransmitfileFN)_PR_InvalidInt, 3090 (PRGetsocknameFN)_PR_InvalidStatus, 3091 (PRGetpeernameFN)_PR_InvalidStatus, 3092 (PRReservedFN)_PR_InvalidInt, 3093 (PRReservedFN)_PR_InvalidInt, 3088 (PRAcceptreadFN)_PR_InvalidInt, 3089 (PRTransmitfileFN)_PR_InvalidInt, 3090 (PRGetsocknameFN)_PR_InvalidStatus, 3091 (PRGetpeernameFN)_PR_InvalidStatus, 3092 (PRReservedFN)_PR_InvalidInt, 3093 (PRReservedFN)_PR_InvalidInt, 3094 3094 (PRGetsocketoptionFN)_PR_InvalidStatus, 3095 3095 (PRSetsocketoptionFN)_PR_InvalidStatus, 3096 (PRSendfileFN)_PR_InvalidInt, 3097 (PRConnectcontinueFN)_PR_InvalidStatus, 3098 (PRReservedFN)_PR_InvalidInt, 3099 (PRReservedFN)_PR_InvalidInt, 3100 (PRReservedFN)_PR_InvalidInt, 3096 (PRSendfileFN)_PR_InvalidInt, 3097 (PRConnectcontinueFN)_PR_InvalidStatus, 3098 (PRReservedFN)_PR_InvalidInt, 3099 (PRReservedFN)_PR_InvalidInt, 3100 (PRReservedFN)_PR_InvalidInt, 3101 3101 (PRReservedFN)_PR_InvalidInt 3102 3102 }; … … 3114 3114 (PRFileInfoFN)_PR_InvalidStatus, 3115 3115 (PRFileInfo64FN)_PR_InvalidStatus, 3116 (PRWritevFN)_PR_InvalidInt, 3117 (PRConnectFN)_PR_InvalidStatus, 3118 (PRAcceptFN)_PR_InvalidDesc, 3119 (PRBindFN)_PR_InvalidStatus, 3120 (PRListenFN)_PR_InvalidStatus, 3121 (PRShutdownFN)_PR_InvalidStatus, 3122 (PRRecvFN)_PR_InvalidInt, 3123 (PRSendFN)_PR_InvalidInt, 3124 (PRRecvfromFN)_PR_InvalidInt, 3125 (PRSendtoFN)_PR_InvalidInt, 3116 (PRWritevFN)_PR_InvalidInt, 3117 (PRConnectFN)_PR_InvalidStatus, 3118 (PRAcceptFN)_PR_InvalidDesc, 3119 (PRBindFN)_PR_InvalidStatus, 3120 (PRListenFN)_PR_InvalidStatus, 3121 (PRShutdownFN)_PR_InvalidStatus, 3122 (PRRecvFN)_PR_InvalidInt, 3123 (PRSendFN)_PR_InvalidInt, 3124 (PRRecvfromFN)_PR_InvalidInt, 3125 (PRSendtoFN)_PR_InvalidInt, 3126 3126 pt_Poll, 3127 (PRAcceptreadFN)_PR_InvalidInt, 3128 (PRTransmitfileFN)_PR_InvalidInt, 3129 (PRGetsocknameFN)_PR_InvalidStatus, 3130 (PRGetpeernameFN)_PR_InvalidStatus, 3131 (PRReservedFN)_PR_InvalidInt, 3132 (PRReservedFN)_PR_InvalidInt, 3127 (PRAcceptreadFN)_PR_InvalidInt, 3128 (PRTransmitfileFN)_PR_InvalidInt, 3129 (PRGetsocknameFN)_PR_InvalidStatus, 3130 (PRGetpeernameFN)_PR_InvalidStatus, 3131 (PRReservedFN)_PR_InvalidInt, 3132 (PRReservedFN)_PR_InvalidInt, 3133 3133 (PRGetsocketoptionFN)_PR_InvalidStatus, 3134 3134 (PRSetsocketoptionFN)_PR_InvalidStatus, 3135 (PRSendfileFN)_PR_InvalidInt, 3136 (PRConnectcontinueFN)_PR_InvalidStatus, 3137 (PRReservedFN)_PR_InvalidInt, 3138 (PRReservedFN)_PR_InvalidInt, 3139 (PRReservedFN)_PR_InvalidInt, 3135 (PRSendfileFN)_PR_InvalidInt, 3136 (PRConnectcontinueFN)_PR_InvalidStatus, 3137 (PRReservedFN)_PR_InvalidInt, 3138 (PRReservedFN)_PR_InvalidInt, 3139 (PRReservedFN)_PR_InvalidInt, 3140 3140 (PRReservedFN)_PR_InvalidInt 3141 3141 }; … … 3172 3172 pt_GetSocketOption, 3173 3173 pt_SetSocketOption, 3174 pt_SendFile, 3174 pt_SendFile, 3175 3175 pt_ConnectContinue, 3176 (PRReservedFN)_PR_InvalidInt, 3177 (PRReservedFN)_PR_InvalidInt, 3178 (PRReservedFN)_PR_InvalidInt, 3176 (PRReservedFN)_PR_InvalidInt, 3177 (PRReservedFN)_PR_InvalidInt, 3178 (PRReservedFN)_PR_InvalidInt, 3179 3179 (PRReservedFN)_PR_InvalidInt 3180 3180 }; … … 3211 3211 pt_GetSocketOption, 3212 3212 pt_SetSocketOption, 3213 (PRSendfileFN)_PR_InvalidInt, 3214 (PRConnectcontinueFN)_PR_InvalidStatus, 3215 (PRReservedFN)_PR_InvalidInt, 3216 (PRReservedFN)_PR_InvalidInt, 3217 (PRReservedFN)_PR_InvalidInt, 3213 (PRSendfileFN)_PR_InvalidInt, 3214 (PRConnectcontinueFN)_PR_InvalidStatus, 3215 (PRReservedFN)_PR_InvalidInt, 3216 (PRReservedFN)_PR_InvalidInt, 3217 (PRReservedFN)_PR_InvalidInt, 3218 3218 (PRReservedFN)_PR_InvalidInt 3219 3219 }; … … 3231 3231 (PRFileInfoFN)_PR_InvalidStatus, 3232 3232 (PRFileInfo64FN)_PR_InvalidStatus, 3233 (PRWritevFN)_PR_InvalidInt, 3234 (PRConnectFN)_PR_InvalidStatus, 3235 (PRAcceptFN)_PR_InvalidDesc, 3236 (PRBindFN)_PR_InvalidStatus, 3237 (PRListenFN)_PR_InvalidStatus, 3238 (PRShutdownFN)_PR_InvalidStatus, 3239 (PRRecvFN)_PR_InvalidInt, 3240 (PRSendFN)_PR_InvalidInt, 3241 (PRRecvfromFN)_PR_InvalidInt, 3242 (PRSendtoFN)_PR_InvalidInt, 3233 (PRWritevFN)_PR_InvalidInt, 3234 (PRConnectFN)_PR_InvalidStatus, 3235 (PRAcceptFN)_PR_InvalidDesc, 3236 (PRBindFN)_PR_InvalidStatus, 3237 (PRListenFN)_PR_InvalidStatus, 3238 (PRShutdownFN)_PR_InvalidStatus, 3239 (PRRecvFN)_PR_InvalidInt, 3240 (PRSendFN)_PR_InvalidInt, 3241 (PRRecvfromFN)_PR_InvalidInt, 3242 (PRSendtoFN)_PR_InvalidInt, 3243 3243 pt_Poll, 3244 (PRAcceptreadFN)_PR_InvalidInt, 3245 (PRTransmitfileFN)_PR_InvalidInt, 3246 (PRGetsocknameFN)_PR_InvalidStatus, 3247 (PRGetpeernameFN)_PR_InvalidStatus, 3248 (PRReservedFN)_PR_InvalidInt, 3249 (PRReservedFN)_PR_InvalidInt, 3244 (PRAcceptreadFN)_PR_InvalidInt, 3245 (PRTransmitfileFN)_PR_InvalidInt, 3246 (PRGetsocknameFN)_PR_InvalidStatus, 3247 (PRGetpeernameFN)_PR_InvalidStatus, 3248 (PRReservedFN)_PR_InvalidInt, 3249 (PRReservedFN)_PR_InvalidInt, 3250 3250 (PRGetsocketoptionFN)_PR_InvalidStatus, 3251 3251 (PRSetsocketoptionFN)_PR_InvalidStatus, 3252 (PRSendfileFN)_PR_InvalidInt, 3253 (PRConnectcontinueFN)_PR_InvalidStatus, 3254 (PRReservedFN)_PR_InvalidInt, 3255 (PRReservedFN)_PR_InvalidInt, 3256 (PRReservedFN)_PR_InvalidInt, 3252 (PRSendfileFN)_PR_InvalidInt, 3253 (PRConnectcontinueFN)_PR_InvalidStatus, 3254 (PRReservedFN)_PR_InvalidInt, 3255 (PRReservedFN)_PR_InvalidInt, 3256 (PRReservedFN)_PR_InvalidInt, 3257 3257 (PRReservedFN)_PR_InvalidInt 3258 3258 }; … … 3306 3306 { 3307 3307 PRFileDesc *fd = _PR_Getfd(); 3308 3308 3309 3309 if (fd == NULL) PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); 3310 3310 else … … 3316 3316 { 3317 3317 /* By default, a Unix fd is not closed on exec. */ 3318 #ifdef DEBUG3319 3318 PRIntn flags; 3320 3319 flags = fcntl(osfd, F_GETFD, 0); 3321 PR_ASSERT(0 == flags); 3322 #endif 3323 fd->secret->inheritable = _PR_TRI_TRUE; 3320 fd->secret->inheritable = flags & FD_CLOEXEC ? _PR_TRI_FALSE : _PR_TRI_TRUE; 3324 3321 } 3325 3322 switch (type) … … 3395 3392 fd->secret->inheritable = _PR_TRI_UNKNOWN; 3396 3393 return fd; 3397 3394 3398 3395 failed: 3399 3396 PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); … … 3464 3461 #if defined(_PR_INET6_PROBE) 3465 3462 if (PR_AF_INET6 == domain) { 3466 if (_pr_ipv6_is_present == PR_FALSE) 3463 if (_pr_ipv6_is_present == PR_FALSE) 3467 3464 domain = AF_INET; 3468 3465 else 3469 3466 domain = AF_INET6; 3470 3467 } 3471 #elif defined(_PR_INET6) 3468 #elif defined(_PR_INET6) 3472 3469 if (PR_AF_INET6 == domain) 3473 3470 domain = AF_INET6; … … 3498 3495 if (fd != NULL) { 3499 3496 /* 3500 * For platforms with no support for IPv6 3497 * For platforms with no support for IPv6 3501 3498 * create layered socket for IPv4-mapped IPv6 addresses 3502 3499 */ … … 3614 3611 pt_MapError(_PR_MD_MAP_ACCESS_ERROR, errno); 3615 3612 return PR_FAILURE; 3616 3613 3617 3614 } /* PR_Access */ 3618 3615 … … 3642 3639 ** a new file at the same time. And we have to hold that lock while we 3643 3640 ** test to see if the file exists and do the rename. The other place 3644 ** where the lock is held is in PR_Open() when possibly creating a 3641 ** where the lock is held is in PR_Open() when possibly creating a 3645 3642 ** new file. 3646 3643 */ … … 4250 4247 } 4251 4248 } 4252 } else 4249 } else 4253 4250 _PR_MD_MAP_SELECT_ERROR(oserror); 4254 4251 } … … 4399 4396 return PR_FAILURE; 4400 4397 } 4398 fcntl(pipefd[0], F_SETFD, FD_CLOEXEC); 4399 fcntl(pipefd[1], F_SETFD, FD_CLOEXEC); 4401 4400 *readPipe = pt_SetMethods(pipefd[0], PR_DESC_PIPE, PR_FALSE, PR_FALSE); 4402 4401 if (NULL == *readPipe) … … 4562 4561 } 4563 4562 PR_Unlock(_pr_flock_lock); 4564 4563 4565 4564 return status; 4566 4565 } /* PR_LockFile */ … … 4580 4579 else fd->secret->lockCount += 1; 4581 4580 PR_Unlock(_pr_flock_lock); 4582 4581 4583 4582 return status; 4584 4583 } /* PR_TLockFile */ … … 4616 4615 struct rlimit rlim; 4617 4616 4618 if ( getrlimit(RLIMIT_NOFILE, &rlim) < 0) 4617 if ( getrlimit(RLIMIT_NOFILE, &rlim) < 0) 4619 4618 return -1; 4620 4619 … … 4644 4643 rlim.rlim_cur = table_size; 4645 4644 4646 if ( setrlimit(RLIMIT_NOFILE, &rlim) < 0) 4645 if ( setrlimit(RLIMIT_NOFILE, &rlim) < 0) 4647 4646 return -1; 4648 4647 … … 4771 4770 if (!pr_set) 4772 4771 return 0; 4773 4772 4774 4773 FD_ZERO(set); 4775 4774 … … 4813 4812 4814 4813 PR_IMPLEMENT(PRInt32) PR_Select( 4815 PRInt32 unused, PR_fd_set *pr_rd, PR_fd_set *pr_wr, 4814 PRInt32 unused, PR_fd_set *pr_rd, PR_fd_set *pr_wr, 4816 4815 PR_fd_set *pr_ex, PRIntervalTime timeout) 4817 4816 { … … 4880 4879 #endif /* defined(_PR_PTHREADS) */ 4881 4880 4882 #ifdef MOZ_UNICODE 4881 #ifdef MOZ_UNICODE 4883 4882 /* ================ UTF16 Interfaces ================================ */ 4884 4883 PR_IMPLEMENT(PRFileDesc*) PR_OpenFileUTF16( -
trunk/src/libs/xpcom18a4/xpcom/threads/plevent.c
r30135 r33044 863 863 return PR_FAILURE; 864 864 } 865 #ifdef VBOX 866 fcntl(self->eventPipe[0], F_SETFD, FD_CLOEXEC); 867 fcntl(self->eventPipe[1], F_SETFD, FD_CLOEXEC); 868 #endif 865 869 866 870 /* make the pipe nonblocking */
Note:
See TracChangeset
for help on using the changeset viewer.