Changeset 33159 in vbox
- Timestamp:
- Oct 15, 2010 12:33:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp
r33064 r33159 105 105 { 106 106 size_t cbToWrite = pStdInBuf->cbSize - pStdInBuf->cbProcessed; 107 int rc = VINF_SUCCESS; 107 #ifdef DEBUG 108 VBoxServiceVerbose(4, "ControlExec: Write StdIn: cbToWrite=%u, cbSize=%u, cbProc=%u\n", 109 cbToWrite, pStdInBuf->cbSize, pStdInBuf->cbProcessed); 110 #endif 108 111 if (cbToWrite && pStdInBuf->fAlive) 109 112 { 110 113 rc = RTPipeWrite(hStdInW, &pStdInBuf->pbData[pStdInBuf->cbProcessed], cbToWrite, pcbWritten); 111 if (RT_SUCCESS(rc)) 114 if ( RT_SUCCESS(rc) 115 && rc != VINF_TRY_AGAIN) 112 116 { 113 117 Assert(*pcbWritten <= cbToWrite); … … 115 119 } 116 120 else 121 { 117 122 *pcbWritten = 0; 118 } 119 else 120 rc = VERR_BAD_PIPE; 123 pStdInBuf->fAlive = false; 124 } 125 #ifdef DEBUG 126 VBoxServiceVerbose(4, "ControlExec: Written StdIn: rc=%Rrc, cbAlloc=%u, cbSize=%u, cbProc=%u, pcbWritten=%u\n", 127 rc, pStdInBuf->cbAllocated, pStdInBuf->cbSize, 128 pStdInBuf->cbProcessed, *pcbWritten); 129 #endif 130 } 131 /*else 132 rc = VERR_BAD_PIPE;*/ 121 133 int rc2 = RTCritSectLeave(&pStdInBuf->CritSect); 122 134 if (RT_SUCCESS(rc)) … … 136 148 * @param phStdInW The standard input pipe. 137 149 * @param pStdInBuf The standard input buffer. 150 * @param pcbWritten 138 151 */ 139 152 static int VBoxServiceControlExecProcHandleStdInWritableEvent(RTPOLLSET hPollSet, uint32_t fPollEvt, PRTPIPE phStdInW, 140 PVBOXSERVICECTRLEXECPIPEBUF pStdInBuf) 141 { 153 PVBOXSERVICECTRLEXECPIPEBUF pStdInBuf, size_t *pcbWritten) 154 { 155 AssertPtrReturn(pcbWritten, VERR_INVALID_PARAMETER); 156 #ifdef DEBUG 142 157 VBoxServiceVerbose(4, "ControlExec: HandleStdInWritableEvent: fPollEvt=%#x\n", fPollEvt); 143 158 #endif 144 159 int rc = VINF_SUCCESS; 145 160 if (!(fPollEvt & RTPOLL_EVT_ERROR)) 146 161 { 147 size_t cbWritten; 148 rc = VBoxServiceControlExecProcWriteStdIn(pStdInBuf, *phStdInW, &cbWritten); 162 rc = VBoxServiceControlExecProcWriteStdIn(pStdInBuf, *phStdInW, pcbWritten); 149 163 if ( RT_FAILURE(rc) 150 164 && rc != VERR_BAD_PIPE) … … 153 167 AssertRC(rc); 154 168 } 155 156 /* No more data to write to stdin? Then remove stdin from poll set. */ 157 if ( cbWritten <= 0 158 || rc == VERR_BAD_PIPE) 159 { 169 else if (/* *pcbWritten <= 0 170 ||*/ rc == VERR_BAD_PIPE) 171 { 172 /* No (more) data to write to stdin? Then remove stdin from poll set. */ 160 173 rc = RTPollSetRemove(hPollSet, VBOXSERVICECTRLPIPEID_STDIN_WRITABLE); 161 174 AssertRC(rc); … … 167 180 } 168 181 169 182 /** 183 * 184 * 185 * @returns IPRT status code. 186 * @param hPollSet 187 * @param fPollEvt 188 * @param phStdInW 189 * @param uHandleId 190 * @param pStdInBuf 191 */ 170 192 static int VBoxServiceControlExecProcHandleInputEvent(RTPOLLSET hPollSet, uint32_t fPollEvt, PRTPIPE phStdInW, 171 193 uint32_t uHandleId, PVBOXSERVICECTRLEXECPIPEBUF pStdInBuf) 172 194 { 195 #ifdef DEBUG 173 196 VBoxServiceVerbose(4, "ControlExec: HandleInputEvent: fPollEvt=%#x\n", fPollEvt); 174 197 #endif 175 198 int rc = VINF_SUCCESS; 176 199 if (fPollEvt & RTPOLL_EVT_ERROR) … … 240 263 241 264 /* 242 * If an error was raised signalled,265 * If an error was signalled, close reading stdout pipe. 243 266 */ 244 267 if (fPollEvt & RTPOLL_EVT_ERROR) … … 327 350 if (RT_SUCCESS(rc2)) 328 351 { 352 #ifdef DEBUG 329 353 VBoxServiceVerbose(4, "ControlExec: RTPollNoResume idPollHnd=%u\n", idPollHnd); 354 #endif 330 355 switch (idPollHnd) 331 356 { … … 336 361 337 362 case VBOXSERVICECTRLPIPEID_STDIN_WRITABLE: 338 rc = VBoxServiceControlExecProcHandleStdInWritableEvent(hPollSet, fPollEvt, &hStdInW, &pData->stdIn); 363 { 364 uint32_t cbWritten; 365 rc = VBoxServiceControlExecProcHandleStdInWritableEvent(hPollSet, fPollEvt, &hStdInW, 366 &pData->stdIn, &cbWritten); 367 if (RT_SUCCESS(rc)) 368 { 369 rc = VbglR3GuestCtrlExecReportStatusIn(pThread->uClientID, pThread->uContextID, pData->uPID, 370 0 /* Flags */, cbWritten); 371 } 339 372 break; 373 } 340 374 341 375 case VBOXSERVICECTRLPIPEID_STDOUT: … … 597 631 pBuf->cbSize = 0; 598 632 pBuf->cbProcessed = 0; 599 pBuf->fAlive = true;633 pBuf->fAlive = false; 600 634 601 635 return RTCritSectInit(&pBuf->CritSect); … … 612 646 pBuf->cbSize = 0; 613 647 pBuf->cbProcessed = 0; 614 }615 pBuf->fAlive = false;648 pBuf->fAlive = false; 649 } 616 650 return RTCritSectDelete(&pBuf->CritSect); 617 651 } … … 656 690 if (RT_SUCCESS(rc)) 657 691 { 658 if (pBuf->fAlive)659 { 692 /*if (pBuf->fAlive) 693 {*/ 660 694 /** @todo Buffer size limit! 4MB */ 661 695 … … 677 711 pBuf->cbSize += cbData; 678 712 /** @todo Add offset clamping! */ 713 pBuf->fAlive = true; 679 714 } 680 715 else 681 716 rc = VERR_NO_MEMORY; 682 }717 //} 683 718 int rc2 = RTCritSectLeave(&pBuf->CritSect); 684 719 if (RT_SUCCESS(rc)) … … 1189 1224 VBoxServiceError("ControlExec: Failed to retrieve exec input command! Error: %Rrc\n", rc); 1190 1225 } 1191 else 1192 { 1226 else if ( cbSize > 0 1227 && cbSize < sizeof(aBuffer)) 1228 { 1229 #ifdef DEBUG 1230 VBoxServiceVerbose(4, "ControlExec: Input (PID %u) received: cbSize=%u\n", uPID, cbSize); 1231 #endif 1193 1232 PVBOXSERVICECTRLTHREAD pNode = VBoxServiceControlExecFindProcess(uPID); 1194 1233 if (pNode) … … 1199 1238 if (RT_SUCCESS(rc)) 1200 1239 { 1240 #ifdef DEBUG 1241 VBoxServiceVerbose(4, "ControlExec: Written to StdIn buffer (PID %u): cbAlloc=%u, cbSize=%u, cbProc=%u\n", 1242 uPID, pData->stdIn.cbAllocated, pData->stdIn.cbSize, 1243 pData->stdIn.cbProcessed); 1244 #endif 1245 #if 0 1201 1246 size_t cbWritten; 1202 1247 rc = VBoxServiceControlExecProcWriteStdIn(&pData->stdIn, pData->pipeStdInW, &cbWritten); 1203 1248 if (RT_SUCCESS(rc)) 1249 { 1204 1250 rc = VbglR3GuestCtrlExecReportStatusIn(u32ClientId, uContextID, uPID, 0 /* Flags */, 1205 1251 cbWritten); 1252 } 1253 #endif 1206 1254 } 1207 1255 } … … 1209 1257 rc = VERR_NOT_FOUND; /* PID not found! */ 1210 1258 } 1259 else 1260 rc = VERR_INVALID_PARAMETER; 1211 1261 VBoxServiceVerbose(3, "ControlExec: VBoxServiceControlExecHandleCmdSetInput returned with %Rrc\n", rc); 1212 1262 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.