IainHull commented on code in PR #385:
URL: https://github.com/apache/incubator-pekko/pull/385#discussion_r1226418876


##########
actor/src/main/scala/org/apache/pekko/io/dns/internal/DnsClient.scala:
##########
@@ -92,23 +101,26 @@ import pekko.pattern.{ BackoffOpts, BackoffSupervisor }
     case Question4(id, name) =>
       log.debug("Resolving [{}] (A)", name)
       val msg = message(name, id, RecordType.A)
-      inflightRequests += (id -> (sender() -> msg))
-      log.debug("Message [{}] to [{}]: [{}]", id, ns, msg)
-      socket ! Udp.Send(msg.write(), ns)
+      newInflightRequests(msg, sender()) {

Review Comment:
   All questions are now protected with `newInflightRequests`. This ensures 
that transaction id is not already in use and the returns the result.



##########
actor/src/main/scala/org/apache/pekko/io/dns/internal/AsyncDnsResolver.scala:
##########
@@ -151,11 +153,19 @@ private[io] final class AsyncDnsResolver(
     }
 
   private def sendQuestion(resolver: ActorRef, message: DnsQuestion): 
Future[Answer] = {
-    val result = (resolver ? message).mapTo[Answer]
-    result.failed.foreach { _ =>
-      resolver ! DropRequest(message.id)
+    (resolver ? message).transformWith {
+      case Success(result: Answer) =>
+        Future.successful(result)
+      case Success(DuplicateId(_)) =>
+        sendQuestion(resolver, message.withId(idGenerator.nextId()))

Review Comment:
   With random transaction ids its possible the id is already in use. If that 
is the case retry with a different transaction id



##########
actor/src/main/scala/org/apache/pekko/io/dns/internal/AsyncDnsResolver.scala:
##########
@@ -41,10 +43,17 @@ import pekko.util.PrettyDuration._
 private[io] final class AsyncDnsResolver(
     settings: DnsSettings,
     cache: SimpleDnsCache,
-    clientFactory: (ActorRefFactory, List[InetSocketAddress]) => 
List[ActorRef])
+    clientFactory: (ActorRefFactory, List[InetSocketAddress]) => 
List[ActorRef],
+    idGenerator: IdGenerator)
     extends Actor
     with ActorLogging {
 
+  def this(

Review Comment:
   This maintains binary compatibility a new parameter with a default value 
does not.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to