Browse Source

[aoe] Start retry timer before potential temporary transmission failure

The retry timer needs to be running as soon as we know that we are
trying to transmit a command.  If transmission fails because of a
temporary error condition, then the timer will allow us to retry the
transmission later.
tags/v0.9.6
Michael Brown 15 years ago
parent
commit
43aa69d7b3
1 changed files with 11 additions and 4 deletions
  1. 11
    4
      src/net/aoe.c

+ 11
- 4
src/net/aoe.c View File

@@ -94,6 +94,13 @@ static int aoe_send_command ( struct aoe_session *aoe ) {
94 94
 		return -ENETUNREACH;
95 95
 	}
96 96
 
97
+	/* If we are transmitting anything that requires a response,
98
+         * start the retransmission timer.  Do this before attempting
99
+         * to allocate the I/O buffer, in case allocation itself
100
+         * fails.
101
+         */
102
+	start_timer ( &aoe->timer );
103
+
97 104
 	/* Calculate count and data_out_len for this subcommand */
98 105
 	count = command->cb.count.native;
99 106
 	if ( count > AOE_MAX_COUNT )
@@ -101,8 +108,8 @@ static int aoe_send_command ( struct aoe_session *aoe ) {
101 108
 	data_out_len = ( command->data_out ? ( count * ATA_SECTOR_SIZE ) : 0 );
102 109
 
103 110
 	/* Create outgoing I/O buffer */
104
-	iobuf = alloc_iob ( ETH_HLEN + sizeof ( *aoehdr ) + sizeof ( *aoecmd ) +
105
-			  data_out_len );
111
+	iobuf = alloc_iob ( ETH_HLEN + sizeof ( *aoehdr ) +
112
+			    sizeof ( *aoecmd ) + data_out_len );
106 113
 	if ( ! iobuf )
107 114
 		return -ENOMEM;
108 115
 	iob_reserve ( iobuf, ETH_HLEN );
@@ -133,7 +140,6 @@ static int aoe_send_command ( struct aoe_session *aoe ) {
133 140
 			 aoe->command_offset, data_out_len );
134 141
 
135 142
 	/* Send packet */
136
-	start_timer ( &aoe->timer );
137 143
 	return net_tx ( iobuf, aoe->netdev, &aoe_protocol, aoe->target );
138 144
 }
139 145
 
@@ -231,7 +237,8 @@ static int aoe_rx_response ( struct aoe_session *aoe, struct aoehdr *aoehdr,
231 237
  * @ret rc		Return status code
232 238
  *
233 239
  */
234
-static int aoe_rx ( struct io_buffer *iobuf, struct net_device *netdev __unused,
240
+static int aoe_rx ( struct io_buffer *iobuf,
241
+		    struct net_device *netdev __unused,
235 242
 		    const void *ll_source ) {
236 243
 	struct aoehdr *aoehdr = iobuf->data;
237 244
 	unsigned int len = iob_len ( iobuf );

Loading…
Cancel
Save