@@ -332,8 +332,32 @@ Sender::handleUnknownPacket(Driver::Packet* packet, Driver* driver)
332332 }
333333
334334 OutMessage::Status status = message->getStatus ();
335- if (status == OutMessage::Status::IN_PROGRESS ||
336- status == OutMessage::Status::SENT) {
335+ assert (status != OutMessage::Status::NOT_STARTED);
336+ if (status != OutMessage::Status::IN_PROGRESS &&
337+ status != OutMessage::Status::SENT) {
338+ // The message is already considered "done" so the UNKNOWN packet
339+ // must be a stale response to a ping.
340+ } else if (message->options & OutMessage::Options::NO_RETRY) {
341+ // Option: NO_RETRY
342+
343+ // Either the Message or the DONE packet was lost; consider the message
344+ // failed since the application asked for the message not to be retried.
345+
346+ // Remove Message from sendQueue.
347+ if (message->numPackets > 1 ) {
348+ SpinLock::Lock lock_queue (queueMutex);
349+ QueuedMessageInfo* info = &message->queuedMessageInfo ;
350+ if (message->state == OutMessage::Status::IN_PROGRESS) {
351+ assert (sendQueue.contains (&info->sendQueueNode ));
352+ sendQueue.remove (&info->sendQueueNode );
353+ }
354+ assert (!sendQueue.contains (&info->sendQueueNode ));
355+ }
356+
357+ bucket->messageTimeouts .cancelTimeout (&message->messageTimeout );
358+ bucket->pingTimeouts .cancelTimeout (&message->pingTimeout );
359+ message->state .store (OutMessage::Status::FAILED);
360+ } else {
337361 // Message isn't done yet so we will restart sending the message.
338362
339363 // Make sure the message is not in the sendQueue before making any
@@ -405,9 +429,6 @@ Sender::handleUnknownPacket(Driver::Packet* packet, Driver* driver)
405429 QueuedMessageInfo::ComparePriority ());
406430 sendReady.store (true );
407431 }
408- } else {
409- // The message is already considered "done" so the UNKNOWN packet
410- // must be a stale response to a ping.
411432 }
412433
413434 driver->releasePackets (&packet, 1 );
@@ -676,9 +697,10 @@ Sender::Message::reserve(size_t count)
676697 * @copydoc Homa::OutMessage::send()
677698 */
678699void
679- Sender::Message::send (Driver::Address destination)
700+ Sender::Message::send (Driver::Address destination,
701+ Sender::Message::Options options)
680702{
681- sender->sendMessage (this , destination);
703+ sender->sendMessage (this , destination, options );
682704}
683705
684706/* *
@@ -730,11 +752,14 @@ Sender::Message::getOrAllocPacket(size_t index)
730752 * Sender::Message to be sent.
731753 * @param destination
732754 * Destination address for this message.
755+ * @param options
756+ * Flags indicating requested non-default send behavior.
733757 *
734758 * @sa dropMessage()
735759 */
736760void
737- Sender::sendMessage (Sender::Message* message, Driver::Address destination)
761+ Sender::sendMessage (Sender::Message* message, Driver::Address destination,
762+ Sender::Message::Options options)
738763{
739764 // Prepare the message
740765 assert (message->driver == driver);
@@ -749,6 +774,7 @@ Sender::sendMessage(Sender::Message* message, Driver::Address destination)
749774
750775 message->id = id;
751776 message->destination = destination;
777+ message->options = options;
752778 message->state .store (OutMessage::Status::IN_PROGRESS);
753779
754780 int actualMessageLen = 0 ;
0 commit comments