- Timestamp:
- Feb 26, 2009 5:32:49 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 43459
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r16981 r17180 7758 7758 E_FAIL); 7759 7759 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) 7760 Utf8Str configFile = aMachine->mData->mConfigFileFull; 7761 char *configFileCP = NULL; 7762 int error; 7763 RTStrUtf8ToCurrentCP (&configFileCP, configFile); 7764 key_t key = ::ftok (configFileCP, 'V'); 7765 RTStrFree (configFileCP); 7760 # ifdef VBOX_WITH_NEW_SYS_V_KEYGEN 7761 AssertCompileSize(key_t, 4); 7762 key_t key; 7763 mIPCSem = -1; 7764 mIPCKey = "0"; 7765 for (uint32_t i = 0; i < 1 << 24; i++) 7766 { 7767 key = ((uint32_t)'V' << 24) | i; 7768 int sem = ::semget (key, 1, S_IRUSR | S_IWUSR | IPC_CREAT | IPC_EXCL); 7769 if (sem < 0 && errno == EEXIST) 7770 continue; 7771 mIPCSem = sem; 7772 if (sem >= 0) 7773 { 7774 mIPCKey = BstrFmt ("%u", key); 7775 break; 7776 } 7777 } 7778 # else /* !VBOX_WITH_NEW_SYS_V_KEYGEN */ 7779 Utf8Str semName = aMachine->mData->mConfigFileFull; 7780 char *pszSemName = NULL; 7781 RTStrUtf8ToCurrentCP (&pszSemName, semName); 7782 key_t key = ::ftok (pszSemName, 'V'); 7783 RTStrFree (pszSemName); 7784 7766 7785 mIPCSem = ::semget (key, 1, S_IRWXU | S_IRWXG | S_IRWXO | IPC_CREAT); 7767 error = errno; 7768 if (mIPCSem < 0 && error == ENOSYS) 7786 # endif /* !VBOX_WITH_NEW_SYS_V_KEYGEN */ 7787 7788 int errnoSave = errno; 7789 if (mIPCSem < 0 && errnoSave == ENOSYS) 7769 7790 { 7770 7791 setError (E_FAIL, … … 7774 7795 return E_FAIL; 7775 7796 } 7776 ComAssertMsgRet (mIPCSem >= 0, ("Cannot create IPC semaphore, errno=%d", err or),7797 ComAssertMsgRet (mIPCSem >= 0, ("Cannot create IPC semaphore, errno=%d", errnoSave), 7777 7798 E_FAIL); 7778 7799 /* set the initial value to 1 */ … … 7895 7916 ::semctl (mIPCSem, 0, IPC_RMID); 7896 7917 mIPCSem = -1; 7918 # ifdef VBOX_WITH_NEW_SYS_V_KEYGEN 7919 mIPCKey = "0"; 7920 # endif /* VBOX_WITH_NEW_SYS_V_KEYGEN */ 7897 7921 #else 7898 7922 # error "Port me!" … … 8059 8083 ::semctl (mIPCSem, 0, IPC_RMID); 8060 8084 mIPCSem = -1; 8085 # ifdef VBOX_WITH_NEW_SYS_V_KEYGEN 8086 mIPCKey = "0"; 8087 # endif /* VBOX_WITH_NEW_SYS_V_KEYGEN */ 8061 8088 #else 8062 8089 # error "Port me!" … … 8118 8145 return S_OK; 8119 8146 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) 8147 # ifdef VBOX_WITH_NEW_SYS_V_KEYGEN 8148 mIPCKey.cloneTo (aId); 8149 # else /* !VBOX_WITH_NEW_SYS_V_KEYGEN */ 8120 8150 mData->mConfigFileFull.cloneTo (aId); 8151 # endif /* !VBOX_WITH_NEW_SYS_V_KEYGEN */ 8121 8152 return S_OK; 8122 8153 #else -
trunk/src/VBox/Main/Makefile.kmk
r17174 r17180 78 78 VBOX_MAIN_DEFS += VBOX_WITH_HOSTNETIF_API 79 79 endif 80 # Unconditionally enable the new semaphore key generation code 81 VBOX_MAIN_DEFS += VBOX_WITH_NEW_SYS_V_KEYGEN 80 82 81 83 VBOX_IDL_FILE.MSCOM = $(VBOX_PATH_SDK)/bindings/mscom/idl/VirtualBox.idl … … 329 331 330 332 ifdef VBOX_WITH_NETFLT 331 #needed to include intsafe.h indirectly included by comdef.h 333 #needed to include intsafe.h indirectly included by comdef.h 332 334 VBoxSVC_INCS.win += $(foreach VARSDK, $(VBoxSVC_SDKS), $(PATH_SDK_$(VARSDK)_INC)/crt) 333 335 #needed to include comsupp.lib -
trunk/src/VBox/Main/SessionImpl.cpp
r16244 r17180 956 956 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) 957 957 958 # ifdef VBOX_WITH_NEW_SYS_V_KEYGEN 959 Utf8Str ipcKey = ipcId; 960 key_t key = RTStrToUInt32(ipcKey.raw()); 961 AssertMsgReturn (key != 0, 962 ("Key value of 0 is not valid for IPC semaphore"), 963 E_FAIL); 964 # else /* !VBOX_WITH_NEW_SYS_V_KEYGEN */ 958 965 Utf8Str semName = ipcId; 959 966 char *pszSemName = NULL; … … 961 968 key_t key = ::ftok (pszSemName, 'V'); 962 969 RTStrFree (pszSemName); 970 # endif /* !VBOX_WITH_NEW_SYS_V_KEYGEN */ 963 971 964 972 mIPCSem = ::semget (key, 0, 0); -
trunk/src/VBox/Main/include/MachineImpl.h
r17156 r17180 988 988 #elif defined (VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) 989 989 int mIPCSem; 990 # ifdef VBOX_WITH_NEW_SYS_V_KEYGEN 991 Bstr mIPCKey; 992 # endif /*VBOX_WITH_NEW_SYS_V_KEYGEN */ 990 993 #else 991 994 # error "Port me!"
Note:
See TracChangeset
for help on using the changeset viewer.