Changes in uspace/srv/net/tl/tcp/tcp.c [86f6121:228e490] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/tcp/tcp.c
r86f6121 r228e490 205 205 static int tcp_queue_received_packet(socket_core_t *, tcp_socket_data_t *, 206 206 packet_t *, int, size_t); 207 static void tcp_queue_received_end_of_data(socket_core_t *socket);208 207 209 208 static int tcp_received_msg(device_id_t, packet_t *, services_t, services_t); … … 454 453 455 454 has_error_service: 456 fibril_rwlock_ write_unlock(&tcp_globals.lock);455 fibril_rwlock_read_unlock(&tcp_globals.lock); 457 456 458 457 /* TODO error reporting/handling */ … … 505 504 size_t offset; 506 505 uint32_t new_sequence_number; 507 bool forced_ack;508 506 int rc; 509 507 … … 514 512 assert(packet); 515 513 516 forced_ack = false;517 518 514 new_sequence_number = ntohl(header->sequence_number); 519 515 old_incoming = socket_data->next_incoming; 520 516 521 if (header->finalize) { 522 socket_data->fin_incoming = new_sequence_number + 523 total_length - TCP_HEADER_LENGTH(header); 524 } 517 if (header->finalize) 518 socket_data->fin_incoming = new_sequence_number; 525 519 526 520 /* Trim begining if containing expected data */ … … 766 760 /* Release duplicite or restricted */ 767 761 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 768 forced_ack = true; 769 } 770 771 /* If next in sequence is an incoming FIN */ 772 if (socket_data->next_incoming == socket_data->fin_incoming) { 773 /* Advance sequence number */ 774 socket_data->next_incoming += 1; 775 776 /* Handle FIN */ 762 } 763 764 /* Change state according to the acknowledging incoming fin */ 765 if (IS_IN_INTERVAL_OVERFLOW(old_incoming, socket_data->fin_incoming, 766 socket_data->next_incoming)) { 777 767 switch (socket_data->state) { 778 768 case TCP_SOCKET_FIN_WAIT_1: … … 781 771 socket_data->state = TCP_SOCKET_CLOSING; 782 772 break; 783 case TCP_SOCKET_ESTABLISHED: 784 /* Queue end-of-data marker on the socket. */ 785 tcp_queue_received_end_of_data(socket); 786 socket_data->state = TCP_SOCKET_CLOSE_WAIT; 787 break; 773 /*case TCP_ESTABLISHED:*/ 788 774 default: 789 775 socket_data->state = TCP_SOCKET_CLOSE_WAIT; … … 793 779 794 780 packet = tcp_get_packets_to_send(socket, socket_data); 795 if (!packet && (socket_data->next_incoming != old_incoming || forced_ack)) {781 if (!packet) { 796 782 /* Create the notification packet */ 797 783 rc = tcp_create_notification_packet(&packet, socket, … … 849 835 850 836 return EOK; 851 }852 853 /** Queue end-of-data marker on the socket.854 *855 * Next element in the sequence space is FIN. Queue end-of-data marker856 * on the socket.857 *858 * @param socket Socket859 */860 static void tcp_queue_received_end_of_data(socket_core_t *socket)861 {862 assert(socket != NULL);863 864 /* Notify the destination socket */865 async_msg_5(socket->phone, NET_SOCKET_RECEIVED,866 (sysarg_t) socket->socket_id,867 0, 0, 0,868 (sysarg_t) 0 /* 0 fragments == no more data */);869 837 } 870 838 … … 1397 1365 1398 1366 case NET_SOCKET_BIND: 1399 res = async_data_write_accept((void **) &addr, false, 1400 0, 0, 0, &addrlen); 1367 res = data_receive((void **) &addr, &addrlen); 1401 1368 if (res != EOK) 1402 1369 break; … … 1435 1402 1436 1403 case NET_SOCKET_CONNECT: 1437 res = async_data_write_accept((void **) &addr, false, 1438 0, 0, 0, &addrlen); 1404 res = data_receive((void **) &addr, &addrlen); 1439 1405 if (res != EOK) 1440 1406 break; … … 1487 1453 1488 1454 case NET_SOCKET_SENDTO: 1489 res = async_data_write_accept((void **) &addr, false, 1490 0, 0, 0, &addrlen); 1455 res = data_receive((void **) &addr, &addrlen); 1491 1456 if (res != EOK) 1492 1457 break; … … 1835 1800 fibril_rwlock_write_unlock(socket_data->local_lock); 1836 1801 1837 socket_data->state = TCP_SOCKET_SYN_SENT;1838 1839 1802 /* Send the packet */ 1840 1803 printf("connecting %d\n", packet_get_id(packet)); … … 2119 2082 if (!fibril) { 2120 2083 free(operation_timeout); 2121 return ENOMEM; 2122 } 2123 2084 return EPARTY; /* FIXME: use another EC */ 2085 } 2124 2086 // fibril_mutex_lock(&socket_data->operation.mutex); 2125 2087 /* Start the timeout fibril */ … … 2244 2206 2245 2207 tcp_prepare_operation_header(socket, socket_data, header, 0, 0); 2246 rc = tcp_queue_packet(socket, socket_data, packet, total_length);2208 rc = tcp_queue_packet(socket, socket_data, packet, 0); 2247 2209 if (rc != EOK) 2248 2210 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.