Commit Graph
340 Commits
Author SHA1 Message Date
Evan HuntandWitold Kręcicki 5febb7e002 fixup! - Always close listening sockets asynchronously, even if we're in the specific thread - Export some lib/ns/client stuff for unit tests - Fix lib/ns unit tests 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 28d4fa2003 fixup! - Always close listening sockets asynchronously, even if we're in the specific thread - Export some lib/ns/client stuff for unit tests - Fix lib/ns unit tests 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 1ac082941c make library wrapping work correctly in the libns unit tests
when LD_WRAP is useable, use it; otherwise, use a "libwrap"
shared library that's linked with '-z interpose' and replaces
isc_nmhandle_unref().
2019-11-05 12:54:45 +01:00
Witold Kręcicki 6dc0edad86 - Free all the pending async calls when the worker is exiting
- Add a hack to fix libuv not sending uv_close callback if nothing
  was in the workqueue
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 2136e7568e fixup! - Always close listening sockets asynchronously, even if we're in the specific thread - Export some lib/ns/client stuff for unit tests - Fix lib/ns unit tests 2019-11-05 12:54:45 +01:00
Witold Kręcicki 4e1bdb2e63 - Always close listening sockets asynchronously, even if we're in the specific thread
- Export some lib/ns/client stuff for unit tests
- Fix lib/ns unit tests
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 26b9212bff unlink from recursing-clients and reset state when resuming from recursion 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 4075fb013c release recursion quota in fetch_callback()
this was previously only done in ns_client_endrequest(), which is
called by client_reset_cb() when a client is released. this could
make the system report more recursive clients than were actually
recursing, and caused intermittent test failures in 'fetchlimit'.
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 026efd2cc8 fully reset the client object before reusing it
not doing so caused unpredictable failures, for example, when
client->rcode_override was set by a previous query and then the
client was reused.
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 1102ec73a7 remove obsolete references to '-T clienttest' 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 7bc1004f00 always reference the client->handle before ns_query_recurse()
this supercedes the experiment in commit eab6c2bff
("attach to nmhandle during zerottl refetch"), and ensures that
the client can't be reset before fetch_callback() is reached.
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki a5ca545f39 more fixes for handle reference counting
- ref handle in tcp_send_direct and tcp_send_cb
- unref handle when xfrout fails
- remove some unneeded unrefs in ns__client_request
2019-11-05 12:54:45 +01:00
Witold Kręcicki 3584565c4b netmgr: fixes for Windows:
- MSVC doesn't like empty {} initializers
 - Emulate stdalign.h on Windows with __declspec(align())
 - There's no usleep on Windows
 - Add missing symbols to libns.def and libisc.def
 - Proper use of SO_REUSE****
 - libuv detection in Configure
 - Minor fixes to the atomics code
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 1b4bbebd11 eliminate isc_nm_shutdown in favor of isc_nm_detach 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki e457feb1e3 continue client/handle reference counting changes 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 021848bca9 experiment: eliminate client reference counting; use nmhandler only 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 669f659fe3 partial fix: improve socket and metmgr cleanup for orderly shudown
- when we attempt to shut down a parent socket, but its children
  still have active handles, the destruction is delayed, and previously
  it was never resumed. now, when the last handle for a child socket is
  detached, we check again whether the parent can be destroyed.
- the netmgr is not shut down until all references to it are detached.
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki b0928cf610 finish some TODO's 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki e8203e3cee documentation and namespace cleanup
- document functions in netmgr.h and netmgr-int.h
- combine identical callback typedefs into one
- remove functions that were never called
- make functions called in only one file static
- rename isc__nm_handle_*() functions to isc__nm_async_*() to avoid
  confusion with the isc__nmhandle type.
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki e75d5cb681 attach the interface when creating clientmgr, rather than assigning
this prevents a potential crash during shutdown when an interface
is destroyed while a client object is still in flight.
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 99689ba839 further ns_client cleanup
- remove unnecessary client->newstate
- clarify purpose of client->next by renaming to client->cleanup
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki b8747be85c fix incorrect initialization of the ns_interface object
this had caused a crash on shutdown in some cases.
2019-11-05 12:54:45 +01:00
Witold Kręcicki 6938bca291 Address compilation errors - gcc overzealousness with empty initializers (C99 declares that those should be filled as static initializers), one uninitialized value 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki f5462083e7 experiment: attach to nmhandle during zerottl refetch 2019-11-05 12:54:45 +01:00
Witold Kręcicki 54d420f391 netmgr:
- clean up isc_nmevent structures - make generic types and just typedef to them
 - fix atomic clang warnings in astack
 - add pause/resume read for TCP
 - add sequential (not-pipelining) support for TCPDNS
 - keep peer address in the socket for TCP connections, it's constant for a socket
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 7a9fc7cf13 remove unused members of ns_client 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki d8a7295bc0 correct accounting of xfrout message length 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 22795df7e5 reattach the nmhandle to the client when running a prefetch
this delays the destruction of the client object until after the
prefetch is finished.

also added some missing CTRACE logging in query.c, in the process of
diagnosing this error.
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 9941edd286 add missing calls to isc_task_unpause()
also more style fixes
2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki f6e42f7e81 Style fixes 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 48b4576318 remove the clienmgr->inactive queue, and the ISC_QUEUE data structure 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki 5eb96c2f90 remove an extra call to isc_nmhandle_detach() 2019-11-05 12:54:45 +01:00
Evan HuntandWitold Kręcicki e91e8f0e2a Style fixes 2019-11-05 12:54:45 +01:00
Witold Kręcicki 356c73d2da Free all extra data in ns_client_t in client_put_cb 2019-11-05 12:54:44 +01:00
Evan HuntandWitold Kręcicki 97c11c43b9 fix reference counting in ns_client and ns_clientmgr
- add reference counters to manager; all client objects attach and
  detach from the manager
- ensure that when a client object is detached, if references have gone
  to zero, the associated nmhandle object is detached. this should
  trigger the freeing of both the nmhandle object and the client object
2019-11-05 12:54:44 +01:00
Evan HuntandWitold Kręcicki c0cd4c1d92 begin cleanup of ns_client
- as client objects are now allocated along with network manager clients
  and will be accounted for by the network manager, there's no longer a
  need to call exit_check(). its functions are now replaced by the
  nmhandle reset and put callbacks.
- there is no need to keep a 'clients' list in ns_clientmgr()
- (however, TODO, the client manager should now be reference counted)
- added some logging to show when clients are allocated, reset, or freed
- ns_client_next() has no remaining function except to log the reason
  for a failure. its name has therefore been changed to ns_client_drop().
2019-11-05 12:54:44 +01:00
Ondřej SurýandWitold Kręcicki ac5ddd3d1f - Some style fixes
- Move typedefs to isc/types.h
2019-11-05 12:54:44 +01:00
Witold Kręcicki 351dab3808 Fix rebase error in lib/ns/client.c 2019-11-05 12:54:44 +01:00
Witold Kręcicki 8b92d20559 netmgr: use portable faaa_queue instead of ck_fifo for event queue.
netmgr: use portable hpstack instead of ck_stack for unused objects cache.
2019-11-05 12:54:44 +01:00
Witold Kręcicki 353d38caf1 Use a per-client task 2019-11-05 12:54:44 +01:00
Ondřej SurýandWitold Kręcicki 41b35d978e Update the whitespaces 2019-11-05 12:54:44 +01:00
Witold Kręcicki 737cc141b6 netmgr: checkpoint: isc_task_pause/unpause - we want to pause client->task when we're processing it outside taskmgr (directly from network thread) 2019-11-05 12:54:44 +01:00
Witold Kręcicki 9b4aab53b3 netmgr: proper closing of TCP/TCPDNS connections, TCP quota support 2019-11-05 12:54:44 +01:00
Witold Kręcicki 841cd63737 netmgr: stop DNS listening, pt 1 2019-11-05 12:54:44 +01:00
Witold Kręcicki 907f983540 netmgr: pause/resume netmgr when going exclusive 2019-11-05 12:54:44 +01:00
Witold Kręcicki fcc05948a1 netmgr: client mctxs divided by thread 2019-11-05 12:54:44 +01:00
Witold Kręcicki 1e6b065a09 nm: WiP: proper udp shutdown procedure 2019-11-05 12:54:44 +01:00
Witold Kręcicki eca6a62716 nm: first xfrout support 2019-11-05 12:54:44 +01:00
Witold Kręcicki 4199eec1fa nm: some style nits, better handling of UDP shutdown 2019-11-05 12:54:44 +01:00
Witold Kręcicki 0de36b4bf0 Netmgr - work in progress (squashed)
- Start netmgr with named, shutdown at the end
- udplistener in interfacemgr uses netmgr
- use per-client buffer for udp send
- first steps at making ns_client_request use netmgr for UDP
- uncrustify
- Make interfacemgr and interface references isc_refcount_t instead of locked ints
- Use clock_gettime instead of gettimeofday
- Cleanup get_client, use one interface for clientmgr instead of attaching it to each client
- 'extra' field at the end of handle - for client data
- clientmgr has a taskpool, clients attach to it
- TCP support
2019-11-05 12:54:44 +01:00