Opened 12 years ago

Closed 12 years ago

#156 closed defect (fixed)

Not enough memory to parse DNS packets in resolver (thanks Frank Wiersma)

Reported by: bennylp Owned by: bennylp
Priority: normal Milestone: release-0.5.10.2
Component: pjlib-util Version: 0.5.10.1
Keywords: Cc:
Backport to 1.x milestone: Backported:

Description

The DNS resolver encounters PJ_ENOMEM error when parsing and duplicating response.

Change History (2)

comment:1 Changed 12 years ago by bennylp

  • Summary changed from Not enough memory to parse DNS packets in resolver to Not enough memory to parse DNS packets in resolver (thanks Frank Wiersma)

comment:2 Changed 12 years ago by bennylp

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in r1033:

  • Optimization in DNS packet data structure to conserve memory
  • Enlarge the size of temporary pool to parse message from 1500 to 4000 (this value is now also controlled by PJ_DNS_RESOLVER_TMP_BUF_SIZE configuration macro.
  • Added flags in pj_dns_packet_dup() to allow exclusions of particular sections in DNS packet (for example, the query, NS, and additional info sections don't need to be kept in a cache in resolver).

Testing:

  • A DNS response with 7 answers, 7 NS records, and 7 additional info records now only need ~1600 bytes of temporary memory to parse it (compared to >1800 previously). Given the size now has been increased to 4000, this should give us plenty of space to spare.
  • Only ~480 bytes of memory is needed to store DNS packet with 7 answer records (previously PJ_ENOMEM will be returned with 512 memory buffer). Given that it's rare to have more than this number of answer records, I think size of 512 should be sufficient. And anyway application can change the value by controlling the PJ_DNS_RESOLVER_RES_BUF_SIZE macro.
Note: See TracTickets for help on using tickets.