G_OBJECT_CLASS (camel_tcp_stream_raw_parent_class)->finalize (object);
}
-static void
-set_errno (gint code)
+void
+_set_errno_from_pr_error (gint pr_code)
{
/* FIXME: this should handle more. */
- switch (code) {
+ switch (pr_code) {
case PR_INVALID_ARGUMENT_ERROR:
errno = EINVAL;
break;
do {
nread = PR_Read (fd, buffer, n);
if (nread == -1)
- set_errno (PR_GetError ());
+ _set_errno_from_pr_error (PR_GetError ());
} while (nread == -1 && (PR_GetError () == PR_PENDING_INTERRUPT_ERROR ||
PR_GetError () == PR_IO_PENDING_ERROR ||
PR_GetError () == PR_WOULD_BLOCK_ERROR));
res = PR_Poll(pollfds, 2, IO_TIMEOUT);
if (res == -1)
- set_errno(PR_GetError());
+ _set_errno_from_pr_error (PR_GetError());
else if (res == 0) {
#ifdef ETIMEDOUT
errno = ETIMEDOUT;
do {
nread = PR_Read (fd, buffer, n);
if (nread == -1)
- set_errno (PR_GetError ());
+ _set_errno_from_pr_error (PR_GetError ());
} while (nread == -1 && PR_GetError () == PR_PENDING_INTERRUPT_ERROR);
}
} while (nread == -1 && (PR_GetError () == PR_PENDING_INTERRUPT_ERROR ||
do {
w = PR_Write (fd, buffer + written, n - written);
if (w == -1)
- set_errno (PR_GetError ());
+ _set_errno_from_pr_error (PR_GetError ());
} while (w == -1 && (PR_GetError () == PR_PENDING_INTERRUPT_ERROR ||
PR_GetError () == PR_IO_PENDING_ERROR ||
PR_GetError () == PR_WOULD_BLOCK_ERROR));
res = PR_Poll (pollfds, 2, IO_TIMEOUT);
if (res == -1) {
- set_errno(PR_GetError());
+ _set_errno_from_pr_error (PR_GetError());
if (PR_GetError () == PR_PENDING_INTERRUPT_ERROR)
w = 0;
} else if (res == 0) {
do {
w = PR_Write (fd, buffer + written, n - written);
if (w == -1)
- set_errno (PR_GetError ());
+ _set_errno_from_pr_error (PR_GetError ());
} while (w == -1 && PR_GetError () == PR_PENDING_INTERRUPT_ERROR);
if (w == -1) {
priv->sockfd = NULL;
if (err)
- set_errno (PR_GetError());
+ _set_errno_from_pr_error (PR_GetError());
else
return 0;
}
fd = PR_OpenTCPSocket(netaddr.raw.family);
if (fd == NULL) {
- set_errno (PR_GetError ());
+ _set_errno_from_pr_error (PR_GetError ());
set_g_error_from_errno (error, FALSE);
return NULL;
}
if (PR_Connect (fd, &netaddr, cancel_fd?0:CONNECT_TIMEOUT) == PR_FAILURE) {
gint errnosave;
- set_errno (PR_GetError ());
+ _set_errno_from_pr_error (PR_GetError ());
if (PR_GetError () == PR_IN_PROGRESS_ERROR ||
(cancel_fd && (PR_GetError () == PR_CONNECT_TIMEOUT_ERROR ||
PR_GetError () == PR_IO_TIMEOUT_ERROR))) {
poll[1].out_flags = 0;
if (PR_Poll (poll, cancel_fd?2:1, CONNECT_TIMEOUT) == PR_FAILURE) {
- set_errno (PR_GetError ());
+ _set_errno_from_pr_error (PR_GetError ());
goto exception;
}
}
if (PR_ConnectContinue(fd, poll[0].out_flags) == PR_FAILURE) {
- set_errno (PR_GetError ());
+ _set_errno_from_pr_error (PR_GetError ());
if (PR_GetError () != PR_IN_PROGRESS_ERROR)
goto exception;
} else {