From: sangorrin Date: Mon, 24 Nov 2008 16:44:37 +0000 (+0000) Subject: BUG corrected: when sending two packets one after the other very fast, the second... X-Git-Url: https://rtime.felk.cvut.cz/gitweb/frescor/fna.git/commitdiff_plain/a7c7d39a87214d10c2553967154cfd543c0f1e31 BUG corrected: when sending two packets one after the other very fast, the second one was overwriting the last_packet variable. Use asserts instead of returning error codes here because if sth fails, everything is wrong.. and it is difficult to debug otherwise git-svn-id: http://www.frescor.org/private/svn/frescor/fna/trunk@1409 35b4ef3e-fd22-0410-ab77-dab3279adceb --- diff --git a/src_frescan/frescan_hw_buffer.c b/src_frescan/frescan_hw_buffer.c index 6fc886e..bc66efb 100644 --- a/src_frescan/frescan_hw_buffer.c +++ b/src_frescan/frescan_hw_buffer.c @@ -72,6 +72,7 @@ #include "frescan_hw_buffer.h" #include // memcpy +#include #include "frescan_data.h" // frescan_data #include "frescan_debug.h" // DEBUG, FRESCAN_ERROR @@ -124,12 +125,12 @@ int frescan_hw_buffer_update(frescan_network_t net) frescan_ss_t id; ret = frescan_servers_get_highest_prio(net, &id, &sprio); - if (ret != 0) return ret; + assert(ret == 0); pqueue = frescan_data[net].queues.tx_fp_queue; ret = frescan_pqueue_get_highest_prio(pqueue, &packet, &fprio); - if (ret != 0) return ret; + assert(ret == 0); if ((id == FRESCAN_MX_IDS) && (packet == NULL)) { DEBUG(FRESCAN_HW_BUFFER_ENABLE_DEBUG, "(ss:0 fp:0)\n"); @@ -154,23 +155,26 @@ int frescan_hw_buffer_update(frescan_network_t net) prio = (is_fp_highest_prio) ? fprio : sprio; is_frame_in_chip = (frescan_data[net].last_packet != NULL); - if (is_frame_in_chip && - (prio > frescan_data[net].last_packet_prio)) { - DEBUG(FRESCAN_HW_BUFFER_ENABLE_DEBUG,"abort frame\n"); - ret = frescan_hw_buffer_abort(net); - if (ret != 0) { - FRESCAN_ERROR ("could not abort frame\n"); - return ret; + if (is_frame_in_chip) { + if (prio > frescan_data[net].last_packet_prio) { + // TODO: if same server, dont abort + DEBUG(FRESCAN_HW_BUFFER_ENABLE_DEBUG, "abort frame\n"); + ret = frescan_hw_buffer_abort(net); + assert(ret == 0); + return 0; + } else { + DEBUG(FRESCAN_HW_BUFFER_ENABLE_DEBUG, + "frame in chip with highest or equal prio\n"); + return 0; } - return 0; } if (is_fp_highest_prio) { ret = frescan_pqueue_dequeue(pqueue, &packet, &prio, 0); - if (ret != 0) return ret; + assert(ret == 0); } else { ret = frescan_servers_dequeue(net, id, &packet, &prio); - if (ret != 0) return ret; + assert(ret == 0); frescan_id_set_field(&packet->frame->id, FRESCAN_FIELD_PRIO,