A small memory footprint AMQP implimentation
Dependents: iothub_client_sample_amqp remote_monitoring simplesample_amqp
Diff: session.c
- Revision:
- 43:4c1e4e94cdd3
- Parent:
- 40:f0ceafa8d570
- Child:
- 44:9dd558f13109
diff -r e2c1c1b77f13 -r 4c1e4e94cdd3 session.c --- a/session.c Fri May 04 13:24:52 2018 -0700 +++ b/session.c Mon Jun 11 15:39:52 2018 -0700 @@ -5,11 +5,17 @@ #include <string.h> #include "azure_c_shared_utility/optimize_size.h" #include "azure_c_shared_utility/gballoc.h" -#include "azure_c_shared_utility/xlogging.h" #include "azure_uamqp_c/session.h" #include "azure_uamqp_c/connection.h" #include "azure_uamqp_c/amqp_definitions.h" +typedef enum LINK_ENDPOINT_STATE_TAG +{ + LINK_ENDPOINT_STATE_NOT_ATTACHED, + LINK_ENDPOINT_STATE_ATTACHED, + LINK_ENDPOINT_STATE_DETACHING +} LINK_ENDPOINT_STATE; + typedef struct LINK_ENDPOINT_INSTANCE_TAG { char* name; @@ -20,6 +26,7 @@ ON_SESSION_FLOW_ON on_session_flow_on; void* callback_context; SESSION_HANDLE session; + LINK_ENDPOINT_STATE link_endpoint_state; } LINK_ENDPOINT_INSTANCE; typedef struct SESSION_INSTANCE_TAG @@ -36,7 +43,7 @@ ON_LINK_ATTACHED on_link_attached; void* on_link_attached_callback_context; - /* Codes_SRS_SESSION_01_016: [next-outgoing-id The next-outgoing-id is the transfer-id to assign to the next transfer frame.] */ + /* Codes_S_R_S_SESSION_01_016: [next-outgoing-id The next-outgoing-id is the transfer-id to assign to the next transfer frame.] */ transfer_number next_outgoing_id; transfer_number next_incoming_id; uint32_t desired_incoming_window; @@ -45,15 +52,69 @@ handle handle_max; uint32_t remote_incoming_window; uint32_t remote_outgoing_window; - int is_underlying_connection_open : 1; + unsigned int is_underlying_connection_open : 1; } SESSION_INSTANCE; #define UNDERLYING_CONNECTION_NOT_OPEN 0 -#define UNDERLYING_CONNECTION_OPEN -1 +#define UNDERLYING_CONNECTION_OPEN 1 + +static void remove_link_endpoint(LINK_ENDPOINT_HANDLE link_endpoint) +{ + if (link_endpoint != NULL) + { + LINK_ENDPOINT_INSTANCE* endpoint_instance = (LINK_ENDPOINT_INSTANCE*)link_endpoint; + SESSION_INSTANCE* session_instance = endpoint_instance->session; + uint32_t i; + + for (i = 0; i < session_instance->link_endpoint_count; i++) + { + if (session_instance->link_endpoints[i] == link_endpoint) + { + break; + } + } + + if (i < session_instance->link_endpoint_count) + { + LINK_ENDPOINT_INSTANCE** new_endpoints; + + if (i < (session_instance->link_endpoint_count - 1)) + { + (void)memmove(&session_instance->link_endpoints[i], &session_instance->link_endpoints[i + 1], (session_instance->link_endpoint_count - (uint32_t)i - 1) * sizeof(LINK_ENDPOINT_INSTANCE*)); + } + + session_instance->link_endpoint_count--; + + if (session_instance->link_endpoint_count == 0) + { + free(session_instance->link_endpoints); + session_instance->link_endpoints = NULL; + } + else + { + new_endpoints = (LINK_ENDPOINT_INSTANCE**)realloc(session_instance->link_endpoints, sizeof(LINK_ENDPOINT_INSTANCE*) * session_instance->link_endpoint_count); + if (new_endpoints != NULL) + { + session_instance->link_endpoints = new_endpoints; + } + } + } + } +} + +static void free_link_endpoint(LINK_ENDPOINT_HANDLE link_endpoint) +{ + if (link_endpoint->name != NULL) + { + free(link_endpoint->name); + } + + free(link_endpoint); +} static void session_set_state(SESSION_INSTANCE* session_instance, SESSION_STATE session_state) { - uint64_t i; + uint32_t i; session_instance->previous_session_state = session_instance->session_state; session_instance->session_state = session_state; @@ -62,7 +123,10 @@ { if (session_instance->link_endpoints[i]->on_session_state_changed != NULL) { - session_instance->link_endpoints[i]->on_session_state_changed(session_instance->link_endpoints[i]->callback_context, session_state, session_instance->previous_session_state); + if (session_instance->link_endpoints[i]->link_endpoint_state != LINK_ENDPOINT_STATE_DETACHING) + { + session_instance->link_endpoints[i]->on_session_state_changed(session_instance->link_endpoints[i]->callback_context, session_state, session_instance->previous_session_state); + } } } } @@ -119,7 +183,7 @@ { /* fatal error */ session_set_state(session_instance, SESSION_STATE_DISCARDING); - (void)connection_close(session_instance->connection, "amqp:internal-error", "Cannot allocate error handle to end session"); + (void)connection_close(session_instance->connection, "amqp:internal-error", "Cannot allocate error handle to end session", NULL); } else { @@ -128,7 +192,7 @@ { /* fatal error */ session_set_state(session_instance, SESSION_STATE_DISCARDING); - (void)connection_close(session_instance->connection, "amqp:internal-error", "Cannot allocate error handle to end session"); + (void)connection_close(session_instance->connection, "amqp:internal-error", "Cannot allocate error handle to end session", NULL); } else { @@ -293,7 +357,7 @@ { SESSION_INSTANCE* session_instance = (SESSION_INSTANCE*)context; - /* Codes_SRS_SESSION_01_060: [If the previous connection state is not OPENED and the new connection state is OPENED, the BEGIN frame shall be sent out and the state shall be switched to BEGIN_SENT.] */ + /* Codes_S_R_S_SESSION_01_060: [If the previous connection state is not OPENED and the new connection state is OPENED, the BEGIN frame shall be sent out and the state shall be switched to BEGIN_SENT.] */ if ((new_connection_state == CONNECTION_STATE_OPENED) && (previous_connection_state != CONNECTION_STATE_OPENED) && (session_instance->session_state == SESSION_STATE_UNMAPPED)) { if (send_begin(session_instance) == 0) @@ -301,12 +365,12 @@ session_set_state(session_instance, SESSION_STATE_BEGIN_SENT); } } - /* Codes_SRS_SESSION_01_061: [If the previous connection state is OPENED and the new connection state is not OPENED anymore, the state shall be switched to DISCARDING.] */ + /* Codes_S_R_S_SESSION_01_061: [If the previous connection state is OPENED and the new connection state is not OPENED anymore, the state shall be switched to DISCARDING.] */ else if ((new_connection_state == CONNECTION_STATE_CLOSE_RCVD) || (new_connection_state == CONNECTION_STATE_END)) { session_set_state(session_instance, SESSION_STATE_DISCARDING); } - /* Codes_SRS_SESSION_09_001: [If the new connection state is ERROR, the state shall be switched to ERROR.] */ + /* Codes_S_R_S_SESSION_09_001: [If the new connection state is ERROR, the state shall be switched to ERROR.] */ else if (new_connection_state == CONNECTION_STATE_ERROR) { session_set_state(session_instance, SESSION_STATE_ERROR); @@ -324,7 +388,7 @@ if (amqpvalue_get_begin(performative, &begin_handle) != 0) { - connection_close(session_instance->connection, "amqp:decode-error", "Cannot decode BEGIN frame"); + connection_close(session_instance->connection, "amqp:decode-error", "Cannot decode BEGIN frame", NULL); } else { @@ -334,7 +398,7 @@ /* error */ begin_destroy(begin_handle); session_set_state(session_instance, SESSION_STATE_DISCARDING); - connection_close(session_instance->connection, "amqp:decode-error", "Cannot get incoming windows and next outgoing id"); + connection_close(session_instance->connection, "amqp:decode-error", "Cannot get incoming windows and next outgoing id", NULL); } else { @@ -349,7 +413,7 @@ session_set_state(session_instance, SESSION_STATE_BEGIN_RCVD); if (send_begin(session_instance) != 0) { - connection_close(session_instance->connection, "amqp:internal-error", "Failed sending BEGIN frame"); + connection_close(session_instance->connection, "amqp:internal-error", "Failed sending BEGIN frame", NULL); session_set_state(session_instance, SESSION_STATE_DISCARDING); } else @@ -387,7 +451,7 @@ { end_session_with_error(session_instance, "amqp:decode-error", "Cannot get link source from ATTACH frame"); } - else if (attach_get_target(attach_handle, &target) != 0) + else if (attach_get_target(attach_handle, &target) != 0) { end_session_with_error(session_instance, "amqp:decode-error", "Cannot get link target from ATTACH frame"); } @@ -410,9 +474,12 @@ } else { + new_link_endpoint->link_endpoint_state = LINK_ENDPOINT_STATE_ATTACHED; + if (!session_instance->on_link_attached(session_instance->on_link_attached_callback_context, new_link_endpoint, name, role, source, target)) { - session_destroy_link_endpoint(new_link_endpoint); + remove_link_endpoint(new_link_endpoint); + free_link_endpoint(new_link_endpoint); new_link_endpoint = NULL; } else @@ -433,6 +500,8 @@ } else { + link_endpoint->link_endpoint_state = LINK_ENDPOINT_STATE_ATTACHED; + link_endpoint->frame_received_callback(link_endpoint->callback_context, performative, payload_size, payload_bytes); } } @@ -470,7 +539,16 @@ } else { - link_endpoint->frame_received_callback(link_endpoint->callback_context, performative, payload_size, payload_bytes); + if (link_endpoint->link_endpoint_state != LINK_ENDPOINT_STATE_DETACHING) + { + link_endpoint->frame_received_callback(link_endpoint->callback_context, performative, payload_size, payload_bytes); + } + else + { + /* remove the link endpoint */ + remove_link_endpoint(link_endpoint); + free_link_endpoint(link_endpoint); + } } } } @@ -492,8 +570,8 @@ if (flow_get_next_incoming_id(flow_handle, &flow_next_incoming_id) != 0) { /* - If the next-incoming-id field of the flow frame is not set, - then remote-incomingwindow is computed as follows: + If the next-incoming-id field of the flow frame is not set, + then remote-incomingwindow is computed as follows: initial-outgoing-id(endpoint) + incoming-window(flow) - next-outgoing-id(endpoint) */ flow_next_incoming_id = session_instance->next_outgoing_id; @@ -522,7 +600,10 @@ if (link_endpoint_instance != NULL) { - link_endpoint_instance->frame_received_callback(link_endpoint_instance->callback_context, performative, payload_size, payload_bytes); + if (link_endpoint_instance->link_endpoint_state != LINK_ENDPOINT_STATE_DETACHING) + { + link_endpoint_instance->frame_received_callback(link_endpoint_instance->callback_context, performative, payload_size, payload_bytes); + } } i = 0; @@ -574,7 +655,10 @@ } else { - link_endpoint->frame_received_callback(link_endpoint->callback_context, performative, payload_size, payload_bytes); + if (link_endpoint->link_endpoint_state != LINK_ENDPOINT_STATE_DETACHING) + { + link_endpoint->frame_received_callback(link_endpoint->callback_context, performative, payload_size, payload_bytes); + } } if (session_instance->incoming_window == 0) @@ -592,7 +676,10 @@ for (i = 0; i < session_instance->link_endpoint_count; i++) { LINK_ENDPOINT_INSTANCE* link_endpoint = session_instance->link_endpoints[i]; - link_endpoint->frame_received_callback(link_endpoint->callback_context, performative, payload_size, payload_bytes); + if (link_endpoint->link_endpoint_state != LINK_ENDPOINT_STATE_DETACHING) + { + link_endpoint->frame_received_callback(link_endpoint->callback_context, performative, payload_size, payload_bytes); + } } } else if (is_end_type_by_descriptor(descriptor)) @@ -613,7 +700,7 @@ if (send_end_frame(session_instance, NULL) != 0) { /* fatal error */ - (void)connection_close(session_instance->connection, "amqp:internal-error", "Cannot send END frame."); + (void)connection_close(session_instance->connection, "amqp:internal-error", "Cannot send END frame.", NULL); } session_set_state(session_instance, SESSION_STATE_DISCARDING); @@ -628,14 +715,14 @@ if (connection == NULL) { - /* Codes_SRS_SESSION_01_031: [If connection is NULL, session_create shall fail and return NULL.] */ + /* Codes_S_R_S_SESSION_01_031: [If connection is NULL, session_create shall fail and return NULL.] */ result = NULL; } else { - /* Codes_SRS_SESSION_01_030: [session_create shall create a new session instance and return a non-NULL handle to it.] */ + /* Codes_S_R_S_SESSION_01_030: [session_create shall create a new session instance and return a non-NULL handle to it.] */ result = (SESSION_INSTANCE*)malloc(sizeof(SESSION_INSTANCE)); - /* Codes_SRS_SESSION_01_042: [If allocating memory for the session fails, session_create shall fail and return NULL.] */ + /* Codes_S_R_S_SESSION_01_042: [If allocating memory for the session fails, session_create shall fail and return NULL.] */ if (result != NULL) { result->connection = connection; @@ -643,8 +730,8 @@ result->link_endpoint_count = 0; result->handle_max = 4294967295u; - /* Codes_SRS_SESSION_01_057: [The delivery ids shall be assigned starting at 0.] */ - /* Codes_SRS_SESSION_01_017: [The nextoutgoing-id MAY be initialized to an arbitrary value ] */ + /* Codes_S_R_S_SESSION_01_057: [The delivery ids shall be assigned starting at 0.] */ + /* Codes_S_R_S_SESSION_01_017: [The nextoutgoing-id MAY be initialized to an arbitrary value ] */ result->next_outgoing_id = 0; result->desired_incoming_window = 1; @@ -659,11 +746,11 @@ result->on_link_attached = on_link_attached; result->on_link_attached_callback_context = callback_context; - /* Codes_SRS_SESSION_01_032: [session_create shall create a new session endpoint by calling connection_create_endpoint.] */ + /* Codes_S_R_S_SESSION_01_032: [session_create shall create a new session endpoint by calling connection_create_endpoint.] */ result->endpoint = connection_create_endpoint(connection); if (result->endpoint == NULL) { - /* Codes_SRS_SESSION_01_033: [If connection_create_endpoint fails, session_create shall fail and return NULL.] */ + /* Codes_S_R_S_SESSION_01_033: [If connection_create_endpoint fails, session_create shall fail and return NULL.] */ free(result); result = NULL; } @@ -719,15 +806,15 @@ void session_destroy(SESSION_HANDLE session) { - /* Codes_SRS_SESSION_01_036: [If session is NULL, session_destroy shall do nothing.] */ + /* Codes_S_R_S_SESSION_01_036: [If session is NULL, session_destroy shall do nothing.] */ if (session != NULL) { SESSION_INSTANCE* session_instance = (SESSION_INSTANCE*)session; session_end(session, NULL, NULL); - /* Codes_SRS_SESSION_01_034: [session_destroy shall free all resources allocated by session_create.] */ - /* Codes_SRS_SESSION_01_035: [The endpoint created in session_create shall be freed by calling connection_destroy_endpoint.] */ + /* Codes_S_R_S_SESSION_01_034: [session_destroy shall free all resources allocated by session_create.] */ + /* Codes_S_R_S_SESSION_01_035: [The endpoint created in session_create shall be freed by calling connection_destroy_endpoint.] */ connection_destroy_endpoint(session_instance->endpoint); if (session_instance->link_endpoints != NULL) { @@ -790,6 +877,7 @@ else { SESSION_INSTANCE* session_instance = (SESSION_INSTANCE*)session; + size_t i; if ((session_instance->session_state != SESSION_STATE_UNMAPPED) && (session_instance->session_state != SESSION_STATE_DISCARDING)) @@ -835,6 +923,14 @@ { result = 0; } + + // all link endpoints are destroyed when the session end happens + for (i = 0; i < session_instance->link_endpoint_count; i++) + { + free_link_endpoint(session_instance->link_endpoints[i]); + } + + session_instance->link_endpoint_count = 0; } return result; @@ -968,7 +1064,7 @@ { LINK_ENDPOINT_INSTANCE* result; - /* Codes_SRS_SESSION_01_044: [If session, name or frame_received_callback is NULL, session_create_link_endpoint shall fail and return NULL.] */ + /* Codes_S_R_S_SESSION_01_044: [If session, name or frame_received_callback is NULL, session_create_link_endpoint shall fail and return NULL.] */ if ((session == NULL) || (name == NULL)) { @@ -976,14 +1072,14 @@ } else { - /* Codes_SRS_SESSION_01_043: [session_create_link_endpoint shall create a link endpoint associated with a given session and return a non-NULL handle to it.] */ + /* Codes_S_R_S_SESSION_01_043: [session_create_link_endpoint shall create a link endpoint associated with a given session and return a non-NULL handle to it.] */ SESSION_INSTANCE* session_instance = (SESSION_INSTANCE*)session; result = (LINK_ENDPOINT_INSTANCE*)malloc(sizeof(LINK_ENDPOINT_INSTANCE)); - /* Codes_SRS_SESSION_01_045: [If allocating memory for the link endpoint fails, session_create_link_endpoint shall fail and return NULL.] */ + /* Codes_S_R_S_SESSION_01_045: [If allocating memory for the link endpoint fails, session_create_link_endpoint shall fail and return NULL.] */ if (result != NULL) { - /* Codes_SRS_SESSION_01_046: [An unused handle shall be assigned to the link endpoint.] */ + /* Codes_S_R_S_SESSION_01_046: [An unused handle shall be assigned to the link endpoint.] */ handle selected_handle = 0; size_t i; size_t name_length; @@ -1004,11 +1100,12 @@ result->callback_context = NULL; result->output_handle = selected_handle; result->input_handle = 0xFFFFFFFF; + result->link_endpoint_state = LINK_ENDPOINT_STATE_NOT_ATTACHED; name_length = strlen(name); result->name = (char*)malloc(name_length + 1); if (result->name == NULL) { - /* Codes_SRS_SESSION_01_045: [If allocating memory for the link endpoint fails, session_create_link_endpoint shall fail and return NULL.] */ + /* Codes_S_R_S_SESSION_01_045: [If allocating memory for the link endpoint fails, session_create_link_endpoint shall fail and return NULL.] */ free(result); result = NULL; } @@ -1021,7 +1118,7 @@ new_link_endpoints = (LINK_ENDPOINT_INSTANCE**)realloc(session_instance->link_endpoints, sizeof(LINK_ENDPOINT_INSTANCE*) * (session_instance->link_endpoint_count + 1)); if (new_link_endpoints == NULL) { - /* Codes_SRS_SESSION_01_045: [If allocating memory for the link endpoint fails, session_create_link_endpoint shall fail and return NULL.] */ + /* Codes_S_R_S_SESSION_01_045: [If allocating memory for the link endpoint fails, session_create_link_endpoint shall fail and return NULL.] */ free(result->name); free(result); result = NULL; @@ -1047,54 +1144,19 @@ void session_destroy_link_endpoint(LINK_ENDPOINT_HANDLE link_endpoint) { - /* Codes_SRS_SESSION_01_050: [If link_endpoint is NULL, session_destroy_link_endpoint shall do nothing.] */ if (link_endpoint != NULL) { LINK_ENDPOINT_INSTANCE* endpoint_instance = (LINK_ENDPOINT_INSTANCE*)link_endpoint; - SESSION_INSTANCE* session_instance = endpoint_instance->session; - uint64_t i; - /* Codes_SRS_SESSION_01_049: [session_destroy_link_endpoint shall free all resources associated with the endpoint.] */ - for (i = 0; i < session_instance->link_endpoint_count; i++) - { - if (session_instance->link_endpoints[i] == link_endpoint) - { - break; - } - } - - if (i < session_instance->link_endpoint_count) + if (endpoint_instance->link_endpoint_state == LINK_ENDPOINT_STATE_ATTACHED) { - LINK_ENDPOINT_INSTANCE** new_endpoints; - - if (i < (session_instance->link_endpoint_count - 1)) - { - (void)memmove(&session_instance->link_endpoints[i], &session_instance->link_endpoints[i + 1], (session_instance->link_endpoint_count - (uint32_t)i - 1) * sizeof(LINK_ENDPOINT_INSTANCE*)); - } - - session_instance->link_endpoint_count--; - - if (session_instance->link_endpoint_count == 0) - { - free(session_instance->link_endpoints); - session_instance->link_endpoints = NULL; - } - else - { - new_endpoints = (LINK_ENDPOINT_INSTANCE**)realloc(session_instance->link_endpoints, sizeof(LINK_ENDPOINT_INSTANCE*) * session_instance->link_endpoint_count); - if (new_endpoints != NULL) - { - session_instance->link_endpoints = new_endpoints; - } - } + endpoint_instance->link_endpoint_state = LINK_ENDPOINT_STATE_DETACHING; } - - if (endpoint_instance->name != NULL) + else { - free(endpoint_instance->name); + remove_link_endpoint(link_endpoint); + free_link_endpoint(link_endpoint); } - - free(endpoint_instance); } } @@ -1113,6 +1175,7 @@ link_endpoint->on_session_state_changed = on_session_state_changed; link_endpoint->on_session_flow_on = on_session_flow_on; link_endpoint->callback_context = context; + link_endpoint->link_endpoint_state = LINK_ENDPOINT_STATE_NOT_ATTACHED; if (link_endpoint->on_session_state_changed != NULL) { @@ -1333,12 +1396,12 @@ return result; } -/* Codes_SRS_SESSION_01_051: [session_send_transfer shall send a transfer frame with the performative indicated in the transfer argument.] */ +/* Codes_S_R_S_SESSION_01_051: [session_send_transfer shall send a transfer frame with the performative indicated in the transfer argument.] */ SESSION_SEND_TRANSFER_RESULT session_send_transfer(LINK_ENDPOINT_HANDLE link_endpoint, TRANSFER_HANDLE transfer, PAYLOAD* payloads, size_t payload_count, delivery_number* delivery_id, ON_SEND_COMPLETE on_send_complete, void* callback_context) { SESSION_SEND_TRANSFER_RESULT result; - /* Codes_SRS_SESSION_01_054: [If link_endpoint or transfer is NULL, session_send_transfer shall fail and return a non-zero value.] */ + /* Codes_S_R_S_SESSION_01_054: [If link_endpoint or transfer is NULL, session_send_transfer shall fail and return a non-zero value.] */ if ((link_endpoint == NULL) || (transfer == NULL)) { @@ -1349,7 +1412,7 @@ LINK_ENDPOINT_INSTANCE* link_endpoint_instance = (LINK_ENDPOINT_INSTANCE*)link_endpoint; SESSION_INSTANCE* session_instance = (SESSION_INSTANCE*)link_endpoint_instance->session; - /* Codes_SRS_SESSION_01_059: [When session_send_transfer is called while the session is not in the MAPPED state, session_send_transfer shall fail and return a non-zero value.] */ + /* Codes_S_R_S_SESSION_01_059: [When session_send_transfer is called while the session is not in the MAPPED state, session_send_transfer shall fail and return a non-zero value.] */ if (session_instance->session_state != SESSION_STATE_MAPPED) { result = SESSION_SEND_TRANSFER_ERROR; @@ -1383,14 +1446,14 @@ } else { - /* Codes_SRS_SESSION_01_012: [The session endpoint assigns each outgoing transfer frame an implicit transfer-id from a session scoped sequence.] */ - /* Codes_SRS_SESSION_01_027: [sending a transfer Upon sending a transfer, the sending endpoint will increment its next-outgoing-id] */ + /* Codes_S_R_S_SESSION_01_012: [The session endpoint assigns each outgoing transfer frame an implicit transfer-id from a session scoped sequence.] */ + /* Codes_S_R_S_SESSION_01_027: [sending a transfer Upon sending a transfer, the sending endpoint will increment its next-outgoing-id] */ *delivery_id = session_instance->next_outgoing_id; if ((transfer_set_handle(transfer, link_endpoint_instance->output_handle) != 0) || (transfer_set_delivery_id(transfer, *delivery_id) != 0) || (transfer_set_more(transfer, false) != 0)) { - /* Codes_SRS_SESSION_01_058: [When any other error occurs, session_send_transfer shall fail and return a non-zero value.] */ + /* Codes_S_R_S_SESSION_01_058: [When any other error occurs, session_send_transfer shall fail and return a non-zero value.] */ result = SESSION_SEND_TRANSFER_ERROR; } else @@ -1400,7 +1463,7 @@ transfer_value = amqpvalue_create_transfer(transfer); if (transfer_value == NULL) { - /* Codes_SRS_SESSION_01_058: [When any other error occurs, session_send_transfer shall fail and return a non-zero value.] */ + /* Codes_S_R_S_SESSION_01_058: [When any other error occurs, session_send_transfer shall fail and return a non-zero value.] */ result = SESSION_SEND_TRANSFER_ERROR; } else @@ -1427,20 +1490,20 @@ if (available_frame_size >= payload_size) { - /* Codes_SRS_SESSION_01_055: [The encoding of the frame shall be done by calling connection_encode_frame and passing as arguments: the connection handle associated with the session, the transfer performative and the payload chunks passed to session_send_transfer.] */ + /* Codes_S_R_S_SESSION_01_055: [The encoding of the frame shall be done by calling connection_encode_frame and passing as arguments: the connection handle associated with the session, the transfer performative and the payload chunks passed to session_send_transfer.] */ if (connection_encode_frame(session_instance->endpoint, transfer_value, payloads, payload_count, on_send_complete, callback_context) != 0) { - /* Codes_SRS_SESSION_01_056: [If connection_encode_frame fails then session_send_transfer shall fail and return a non-zero value.] */ + /* Codes_S_R_S_SESSION_01_056: [If connection_encode_frame fails then session_send_transfer shall fail and return a non-zero value.] */ result = SESSION_SEND_TRANSFER_ERROR; } else { - /* Codes_SRS_SESSION_01_018: [is incremented after each successive transfer according to RFC-1982 [RFC1982] serial number arithmetic.] */ + /* Codes_S_R_S_SESSION_01_018: [is incremented after each successive transfer according to RFC-1982 [RFC1982] serial number arithmetic.] */ session_instance->next_outgoing_id++; session_instance->remote_incoming_window--; session_instance->outgoing_window--; - /* Codes_SRS_SESSION_01_053: [On success, session_send_transfer shall return 0.] */ + /* Codes_S_R_S_SESSION_01_053: [On success, session_send_transfer shall return 0.] */ result = SESSION_SEND_TRANSFER_OK; } } @@ -1556,7 +1619,7 @@ } else { - /* Codes_SRS_SESSION_01_018: [is incremented after each successive transfer according to RFC-1982 [RFC1982] serial number arithmetic.] */ + /* Codes_S_R_S_SESSION_01_018: [is incremented after each successive transfer according to RFC-1982 [RFC1982] serial number arithmetic.] */ session_instance->next_outgoing_id++; session_instance->remote_incoming_window--; session_instance->outgoing_window--;