Browse Source

Minor optimization in send_file_data

bel 10 years ago
parent
commit
7418dc78df
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/civetweb.c

+ 4 - 4
src/civetweb.c

@@ -5106,9 +5106,11 @@ static void send_file_data(struct mg_connection *conn,
 	int to_read, num_read, num_written;
 	int64_t size;
 
+	if (!filep || !conn) {
+		break;
+	}
+
 	/* Sanity check the offset */
-	if (!filep)
-		return;
 	size = filep->size > INT64_MAX ? INT64_MAX : (int64_t)(filep->size);
 	offset = offset < 0 ? 0 : offset > size ? size : offset;
 
@@ -5141,8 +5143,6 @@ static void send_file_data(struct mg_connection *conn,
 			}
 
 			/* Both read and were successful, adjust counters */
-			if (!conn)
-				break;
 			conn->num_bytes_sent += num_written;
 			len -= num_written;
 		}