我正在尝试向geoip
powerdnsgmysql
后端添加功能。修改 lookup() 函数 - 在pdns/backends/gsql/gsqlbackend.hh
GeoIP * gi;
GeoIPRegion *region;
在pdns/backends/gsql/gsqlbackend.hh
gi = GeoIP_open_type(GEOIP_REGION_EDITION_REV1, GEOIP_STANDARD);
region = GeoIP_region_by_addr(gi, pkt_p->getRemote().c_str());
编译pdns
成功,但是当我提出请求时,我陷入了sigsegv
.
痕迹
pdns[29271]: Got a signal 11, attempting to print trace:
pdns[29271]: Got a signal 11, attempting to print trace:
pdns[29271]: /usr/sbin/pdns_server-instance() [0x4b2e52]
pdns[29271]: /usr/sbin/pdns_server-instance() [0x4b2e52]
pdns[29271]: /lib/libc.so.6(+0x321e0) [0x7f666c2041e0]
pdns[29271]: /lib/libc.so.6(+0x321e0) [0x7f666c2041e0]
pdns[29271]: /usr/lib64/libGeoIP.so.1(GeoIP_region_by_addr+0x9) [0x7f666d15b989]
pdns[29271]: /usr/lib64/libGeoIP.so.1(GeoIP_region_by_addr+0x9) [0x7f666d15b989]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN11GSQLBackend6lookupERK5QTypeRKSsP9DNSPacketi+0xa26) [0x5307a6]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN11GSQLBackend6lookupERK5QTypeRKSsP9DNSPacketi+0xa26) [0x5307a6]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN10DNSBackend6getSOAERKSsR7SOADataP9DNSPacket+0x4f) [0x49923f]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN10DNSBackend6getSOAERKSsR7SOADataP9DNSPacket+0x4f) [0x49923f]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN12UeberBackend6getSOAERKSsR7SOADataP9DNSPacket+0xb5) [0x4c1f95]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN12UeberBackend6getSOAERKSsR7SOADataP9DNSPacket+0xb5) [0x4c1f95]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN13PacketHandler7getAuthEP9DNSPacketP7SOADataRKSsPi+0x3d) [0x46c14d]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN13PacketHandler7getAuthEP9DNSPacketP7SOADataRKSsPi+0x3d) [0x46c14d]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN13PacketHandler17questionOrRecurseEP9DNSPacketPb+0xc41) [0x4729f1]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN13PacketHandler17questionOrRecurseEP9DNSPacketPb+0xc41) [0x4729f1]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN13PacketHandler8questionEP9DNSPacket+0x20) [0x475e70]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN13PacketHandler8questionEP9DNSPacket+0x20) [0x475e70]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN11DistributorI9DNSPacketS0_13PacketHandlerE10makeThreadEPv+0x2ef) [0x507ecf]
pdns[29271]: /usr/sbin/pdns_server-instance(_ZN11DistributorI9DNSPacketS0_13PacketHandlerE10makeThreadEPv+0x2ef) [0x507ecf]
pdns[29271]: /lib/libpthread.so.0(+0x68c4) [0x7f666c5318c4]
pdns[29271]: /lib/libpthread.so.0(+0x68c4) [0x7f666c5318c4]
pdns[29271]: /lib/libc.so.6(clone+0x6d) [0x7f666c2a2fdd]
pdns[29271]: /lib/libc.so.6(clone+0x6d) [0x7f666c2a2fdd]
pdns[29262]: Our pdns instance (29271) exited after signal 6
pdns[29262]: Our pdns instance (29271) exited after signal 6
我发现我正在使用GeoIP_region_by_addr()
,有什么建议吗?
更新:
我研究了Geoip.so
代码-
static GeoIPRegion * _get_region(GeoIP* gi, unsigned long ipnum) {
GeoIPRegion * region;
region = malloc(sizeof(GeoIPRegion));
if (region) {
GeoIP_assign_region_by_inetaddr(gi, htonl(ipnum), region);
}
return region;
}
我认为问题出在线程中的请求操作malloc()
期间。关于解决问题的任何想法?geo
powerdns