summaryrefslogtreecommitdiff
path: root/librabbitmq/amqp_connection.c
diff options
context:
space:
mode:
authorDavid Wragg <dpw@lshift.net>2010-05-30 23:31:40 +0100
committerDavid Wragg <dpw@lshift.net>2010-05-30 23:31:40 +0100
commit66a0a987914626fc0ea86067a0ea1dd7a2bebdd2 (patch)
tree0e400acdd2e7f35ed47b94d51308b142e82dbeac /librabbitmq/amqp_connection.c
parent7e8fbea4c9212774c101e33218d26a0dc992dc03 (diff)
downloadrabbitmq-c-github-ask-66a0a987914626fc0ea86067a0ea1dd7a2bebdd2.tar.gz
Make error codes returned by librabbitmq functions opaque
Windows doesn't generally use POSIX error codes, which poses a problem for librabbitmq's approach of using those error codes in its API. So make the librabbitmq error codes opaque: They are still be integers, but client code is not supposed to assume anything about them, except that they can be passed to a new amqp_error_string() function which returns the corresponding error message Internally, the error codes are either taken from a set of librabbitmq-specific values, or correspond to an OS-specific (POSIX or win32) error code, with a simple encoding to indicate which is which.
Diffstat (limited to 'librabbitmq/amqp_connection.c')
-rw-r--r--librabbitmq/amqp_connection.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/librabbitmq/amqp_connection.c b/librabbitmq/amqp_connection.c
index 7531fac..4fdc71e 100644
--- a/librabbitmq/amqp_connection.c
+++ b/librabbitmq/amqp_connection.c
@@ -151,7 +151,7 @@ int amqp_tune_connection(amqp_connection_state_t state,
newbuf = realloc(state->outbound_buffer.bytes, frame_max);
if (newbuf == NULL) {
amqp_destroy_connection(state);
- return -ENOMEM;
+ return -ERROR_NO_MEMORY;
}
state->outbound_buffer.bytes = newbuf;
@@ -174,7 +174,7 @@ int amqp_end_connection(amqp_connection_state_t state) {
int s = state->sockfd;
amqp_destroy_connection(state);
if (close(s) < 0)
- return -errno;
+ return -encoded_errno();
else
return 0;
}
@@ -208,7 +208,7 @@ int amqp_handle_input(amqp_connection_state_t state,
/* state->inbound_buffer.len is always nonzero, because it
corresponds to frame_max, which is not permitted to be less
than AMQP_FRAME_MIN_SIZE (currently 4096 bytes). */
- return -ENOMEM;
+ return -ERROR_NO_MEMORY;
}
state->state = CONNECTION_STATE_WAITING_FOR_HEADER;
}
@@ -255,7 +255,7 @@ int amqp_handle_input(amqp_connection_state_t state,
/* Check frame end marker (footer) */
if (D_8(state->inbound_buffer, state->target_size - 1) != AMQP_FRAME_END) {
- return -EINVAL;
+ return -ERROR_BAD_AMQP_DATA;
}
decoded_frame->channel = D_16(state->inbound_buffer, 1);
@@ -401,7 +401,7 @@ static int inner_send_frame(amqp_connection_state_t state,
break;
default:
- return -EINVAL;
+ abort();
}
E_32(state->outbound_buffer, 3, *payload_len);