Skip to content

Commit

Permalink
- Userspace code now runs properly on XP x86.
Browse files Browse the repository at this point in the history
- Userspace code now shows the internal error for recv() functions on usbip_xmit instead of just returning -1 (useful for debugging).
  • Loading branch information
rgsilva committed Apr 5, 2012
1 parent f515139 commit 989e8f9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions userspace/src/usbip_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,23 @@ static ssize_t usbip_xmit(int sockfd, void *buff, size_t bufflen, int sending)
if (sending)
nbytes = send(sockfd, buff, bufflen, 0);
else
nbytes = recv(sockfd, buff, bufflen, MSG_WAITALL);
nbytes = recv(sockfd, buff, bufflen, 0);

if (nbytes <= 0) {
LPVOID lpMsgBuf;

// Get error information.
int err = WSAGetLastError();

if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL)) {
fprintf(stderr, "[usbip_xmit] recv() returned %d - error %d: %s\n", nbytes, err, lpMsgBuf);
LocalFree(lpMsgBuf);
} else {
fprintf(stderr, "[usbip_xmit] recv() returned %d - error %d\n", nbytes, err);
}

if (nbytes <= 0)
return -1;
}

buff = (void *) ((intptr_t) buff + nbytes);
bufflen -= nbytes;
Expand Down

0 comments on commit 989e8f9

Please sign in to comment.