summaryrefslogtreecommitdiff
path: root/tests/sock.c
Commit message (Collapse)AuthorAge
* fixes #1032 Figure out Darwin bustednessGarrett D'Amore2019-12-24
| | | | | | | | | | | | | | | | | | | | | | | | fixes #1035 Convey is awkward -- consider acutest.h This represents a rather large effort towards cleaning up our testing and optional configuration infrastructure. A separate test library is built by default, which is static, and includes some useful utilities design to make it easier to write shorter and more robust (not timing dependent) tests. This also means that we can cover pretty nearly all the tests (protocols etc.) in every case, even if the shipped image will be minimized. Subsystems which are optional can now use a few new macros to configure what they need see nng_sources_if, nng_headers_if, and nng_defines_if. This goes a long way to making the distributed CMakefiles a lot simpler. Additionally, tests for different parts of the tree can now be located outside of the tests/ tree, so that they can be placed next to the code that they are testing. Beyond the enabling work, the work has only begun, but these changes have resolved the most often failing tests for Darwin in the cloud.
* move all public headers to include/nng/ folderGregor Burger2018-11-22
| | | | | | | | | | This change makes embedding nng + nggpp (or other projects depending on nng) in cmake easier. The header files are moved to a separate include directory. This also makes installation of the headers easier, and allows clearer identification of private vs public heade files. Some additional cleanups were performed by @gedamore, but the main credit for this change belongs with @gregorburger.
* fixes #766 NNG asserts when setting socket nameGarrett D'Amore2018-11-01
| | | | Reported by @TBastiani (with suggested fix). Test validation added.
* fixes #568 Want a single reader/write lock on socket child objectsGarrett D'Amore2018-07-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #170 Make more use of reaper This is a complete restructure/rethink of how child objects interact with the socket. (This also backs out #576 as it turns out not to be needed.) While 568 says reader/writer lock, for now we have settled for a single writer lock. Its likely that this is sufficient. Essentially we use the single socket lock to guard lists of the socket children. We also use deferred deletion in the idhash to facilitate teardown, which means endpoint closes are no longer synchronous. We use the reaper to clean up objects when the reference count drops to zero. We make a special exception for pipes, since they really are not reference counted by their parents, and they are leaf objects anyway. We believe this addresses the main outstanding race conditions in a much more correct and holistic way. Note that endpoint shutdown is a little tricky, as it makes use of atomic flags to guard against double entry, and against recursive lock entry. This is something that would be nice to make a bit more obvious, but what we have is safe, and the complexity is at least confined to one place.
* fixes #564 Race regression caused by#522Garrett D'Amore2018-07-02
| | | | | | fixes #565 Option getting should validate sizes more aggressively fixes #563 Reconnect timeouts should be settable on dialers fixes #562 pipe test is fragile
* fixes #522 Separate out the endpoint plumbingGarrett D'Amore2018-06-27
| | | | | | | | | | This separates the plumbing for endpoints into distinct dialer and listeners. Some of the transports could benefit from further separation, but we've done some rather larger separation e.g. for the websocket transport. IPC would be a good one to update later, when we start looking at exposing a more natural underlying API.
* fixes #486 Revisit SOVERSION and VERSIONGarrett D'Amore2018-05-25
| | | | | | | | | | | | | | | | | | | | | | fixes #485 Honor BUILD_SHARED_LIBS fixes #483 Don't expose private symbols in shared library fixes #481 Export CMake target This is a "large" commit involving changes that don't affect the code directly, but which have an impact on how we package and build our project. The most significant of these changes is that we now build only either a shared or a static library, depending on the setting of the BUILD_SHARED_LIBS option. We also suppress private symbols from being exposed when the underlying toolchain lets us do so. Minor updates to the way we version the ABI are used, and we now have a nice exported CMake project. To import this project in another, simply do find_package(nng) and you can add target_link_libraries(nng::nng) to your targets. CMake does the rest for you.
* fixes #381 Want comparators for various typesGarrett D'Amore2018-05-01
|
* fixes #375 integer types are error proneGarrett D'Amore2018-04-26
| | | | | | | | | | | | | | This change converts the various integer types like nng_socket in the public API to opaque structures that are passed by value. Basically we just wrap the integer ID. This "hack" give us strong type checks by the compiler (yay!), at the expense of not being able to directly use these as numbers (so comparisions for example don't work, and neither does initialization to zero using the normal method. Comparison of disassembly output shows that at least with the optimizer enabled there is no difference in the compiler output between using a structure or an integral value.
* fixes #308 Close can blockGarrett D'Amore2018-04-14
| | | | | | | | | | | | | | | | | | | | Ultimately, this just removes the support for lingering altogether. Based on prior experience, lingering has always been unreliable, and was removed in legacy libnanomsg ages ago. The problem is that operating system support for lingering is very inconsistent at best, and for some transports the very concept is somewhat meaningless. Making things worse, we were never able to adequately capture an exit() event from another thread -- so lingering was always a false promise. Applications that need to be sure that messages are delivered should either include an ack in their protocol, use req/rep (which has an ack), or inject a suitable delay of their own. For things going over local networks, an extra delay of 100 msec should be sufficient *most of the time*.
* fixes #331 replace NNG_OPT_RAW option with constructorGarrett D'Amore2018-04-04
| | | | | | | | | | | | | This makes the raw mode something that is immutable, determined at socket construction. This is an enabling change for the separate context support coming soon. As a result, this is an API breaking change for users of the raw mode option (NNG_OPT_RAW). There aren't many of them out there. Cooked mode is entirely unaffected. There are changes to tests and documentation included.
* fixes #329 type checking not done for setoptGarrett D'Amore2018-04-04
|
* fixes #301 String option handling for getoptGarrett D'Amore2018-03-20
|
* fixes #296 Typed options should validate option typeGarrett D'Amore2018-03-20
| | | | | | | | | | | | | fixes #302 nng_dialer/listener/pipe_getopt_sockaddr desired This adds plumbing to pass and check the type of options all the way through. NNG_ZT_OPT_ORBIT is type UINT64, but you can use the untyped form to pass two of them if needed. No typed access for retrieving strings yet. I think this should allocate a pointer and copy that out, but that's for later.
* fixes #295 boolean options should use C99 bool typeGarrett D'Amore2018-03-18
| | | | | | | | | | | fixes #275 nng_pipe_getopt_ptr() missing? fixes #285 nng_setopt_ptr MIS fixes #297 nng_listener/dialer_close does not validate mode This change adds some missing APIs, and changes others. In particular, certain options are now of type bool, with size of just one. This is a *breaking* change for code that uses those options -- NNG_OPT_RAW, NNG_OPT_PAIR1_POLY, NNG_OPT_TLS_VERIFIED.
* fixes #287 remove NNG_OPT_DOMAIN, NNG_OPT_PROTOCOL, and NNG_OPT_TRANSPORTGarrett D'Amore2018-03-17
| | | | | While here we documented that certain options are not supported in the compatibility layer.
* Introduce 'porting layer' Public API.Garrett D'Amore2018-02-20
| | | | | | | This introduces portable primitives for time, random numbers, synchronization primitives, and threading. These are somewhat primitive (least common denominiators), but they can help with writing portable applications, especially our own demo apps.
* fixes #234 Investigate enabling more verbose compiler warningsGarrett D'Amore2018-02-14
| | | | | | | We enabled verbose compiler warnings, and found a lot of issues. Some of these were even real bugs. As a bonus, we actually save some initialization steps in the compat layer, and avoid passing some variables we don't need.
* fixes #143 Protocols and transports should be "configurable"Garrett D'Amore2017-11-02
| | | | | | | | | | | | | | | | | | | | This makes all the protocols and transports optional. All of them except ZeroTier are enabled by default, but you can now disable them (remove from the build) with cmake options. The test suite is modified so that tests still run as much as they can, but skip over things caused by missing functionality from the library (due to configuration). Further, the constant definitions and prototypes for functions that are specific to transports or protocols are moved into appropriate headers, which should be included directly by applications wishing to use these. We have also added and improved documentation -- all of the transports are documented, and several more man pages for protocols have been added. (Req/Rep and Surveyor are still missing.)
* fixes #137 Remove public access to numeric protocolsGarrett D'Amore2017-10-31
|
* fixes #136 consider eliminating nng_shutdownGarrett D'Amore2017-10-30
|
* fixes #84 Consider using msec for durationsGarrett D'Amore2017-10-19
| | | | | | There is now a public nng_duration type. We have also updated the zerotier work to work with the signed int64_t's that the latst ZeroTier dev branch is using.
* Add NNG_OPT_DOMAIN and NNG_OPT_SOCKNAME support for legacy compat.Garrett D'Amore2017-10-06
| | | | | | | | The NNG_OPT_SOCKNAME option is settable, to a limit of 64 bytes. The NNG_OPT_DOMAIN is read-only, but changes to match the setting of the NNG_OPT_RAW field. New applications should not use the NNG_OPT_DOMAIN option -- it is provided solely for use with the legacy NN_DOMAIN option in the compatibility layer.
* Added more complete tests, and changes to property handling.Garrett D'Amore2017-10-02
| | | | | | | | | | | | | | | | We allow some properties to be set on endpoints after they are started; transports now responsible for checking that. (The new values will only apply to new connections of course!) We added short-hand functions for pipe properties, and also added uint64_t shorthands across the board. The zerotier documentation got some updates (corrections). We have also added a separate header now for the ZT stuff. Also, dialers and listeners do not intermix anymore -- we test that only a dialer can be used with setting dialer options, and likewise for listeners.
* Refactor option handling APIs.Garrett D'Amore2017-09-27
| | | | | | | | | | | | This makes the APIs use string keys, and largely eliminates the use of integer option IDs altogether. The underlying registration for options is also now a bit richer, letting protcols and transports declare the actual options they use, rather than calling down into each entry point carte blanche and relying on ENOTSUP. This code may not be as fast as the integers was, but it is more intuitive, easier to extend, and is not on any hot code paths. (If you're diddling options on a hot code path you're doing something wrong.)
* ZeroTier transport implementation (work funded by Capitar IT Group BV)Garrett D'Amore2017-09-26
| | | | | | | | | | | | | The ZeroTier transport is experimental at this point, and not enabled by default. It does not work with Windows yet (the Windows platform needs UDP support first.) Configure with -DNNG_ENABLE_ZEROTIER=yes -DNNG_ZEROTIER_SOUCE=<path> The <path> must point to a dev branch of the ZeroTierOne source tree, checked out, and built with a libzerotiercore.a in the top directory, and a ZeroTierOne.h header located at include. The build will add -lc++ to the compile, as the ZeroTier core functionality is written in C++ and needs some runtime support (e.g. new, delete, etc.)
* More pipe option handling, pipe API support. Url option.Garrett D'Amore2017-09-22
| | | | | | | | | | This fleshes most of the pipe API out, making it available to end user code. It also adds a URL option that is independent of the address options (which would be sockaddrs.) Also, we are now setting the pipe for req/rep. The other protocols need to have the same logic added to set the receive pipe on the message. (Pair is already done.)
* Eliminate legacy option settings, provide easier option IDs.Garrett D'Amore2017-08-24
| | | | | | | | | | | | | | | | | | This eliminates all the old #define's or enum values, making all option IDs now totally dynamic, and providing well-known string values for well-behaved applications. We have added tests of some of these options, including lookups, and so forth. We have also fixed a few problems; including at least one crasher bug when the timeouts on reconnect were zero. Protocol specific options are now handled in the protocol. We will be moving the initialization for a few of those well known entities to the protocol startup code, following the PAIRv1 pattern, later. Applications must therefore not depend on the value of the integer IDs, at least until the application has opened a socket of the appropriate type.
* Endpoint API completely implemented.Garrett D'Amore2017-08-18
| | | | | | This supports creating listeners and dialers, managing options on them (though only a few options are supported at present), starting them and closing them, all independently.
* Convert duration to usec.Garrett D'Amore2017-08-14
|
* fixes #63 NNG_FLAG_SYNCH should be the defaultGarrett D'Amore2017-08-14
| | | | | Also enables creating endpoints that are idle (first part of endpoint options API) and shutting down endpoints.
* Idempotent taskq finalizers.Garrett D'Amore2017-08-14
|
* Convenience option accesor functions.Garrett D'Amore2017-08-12
| | | | | | | | This adds functions that know about option sizes and make them easier to use. While here I added some validation of those, and cleaned up a few tests slightly. Note that we do not need to use the nng_impl.h for most tests. More of them need to be cleaned up.
* Windows fixes; especially idempotent init/fini.Garrett D'Amore2017-08-11
| | | | | | | This fixes one major problem, which was that if nni_fini() was called once on Windows, it would not be further possible to call nni_init(). While here fixed a few compilation issues.
* Leaking poll fds.Garrett D'Amore2017-08-11
| | | | | | | We never set the fd->sn_init member, causing new fds to be allocated on each request for a new pollfd, and causing old ones to leak, and worse may be even to not get notified. While here, we arrange for a bit richer testing against the various options.
* fixes #44 open protocol by "name" (symbol) instead numberGarrett D'Amore2017-08-09
| | | | | | | | | | | | | | fixes #38 Make protocols "pluggable", or at least optional This is a breaking change, as we've done away with the central registered list of protocols, and instead demand the user call nng_xxx_open() where xxx is a protocol name. (We did keep a table around in the compat framework though.) There is a nice way for protocols to plug in via an nni_proto_open(), where they can use a generic constructor that they use to build a protocol specific constructor (passing their ops vector in.)
* Make reqrep test more robust; sock test faster.Garrett D'Amore2017-06-25
|
* Fix leaks in bus, socket leaks, tighten up close-side refcnting.Garrett D'Amore2017-01-21
| | | | | | | | | | | | | | This does a few things. First it closes some preexisting leaks. Second it tightens the overall close logic so that we automatically discard idhash resources (while keeping numeric values for next id etc. around) when the last socket is closed. This then eliminates the need for applications to ever explicitly terminate resources. It turns out platform-specific resources established at nni_init() time might still be leaked, but it's also the case that we now no longer dynamically allocate anything at platform initialization time. (This presumes that the platform doesn't do so under the hood when creating critical sections or mutexes for example.)
* Implement nng_send and nng_recv convenience routines.Garrett D'Amore2017-01-21
|
* Dangling compiler warnings from sock handle change.Garrett D'Amore2017-01-20
|
* fixes #18 Sockets should be uint32_t's (handles) not pointers.Garrett D'Amore2017-01-20
|
* Windows compilation fixes.Garrett D'Amore2017-01-18
|
* Fixes for valgrind issues.Garrett D'Amore2017-01-18
|
* Various complaints found in AppVeyor build.Garrett D'Amore2017-01-16
|
* Use Windows tick clock instead of Performance counters.Garrett D'Amore2017-01-14
| | | | | | | | | | | | Since we use the tick counter to sleep, we should use the same clock for validation. The problem is that the high performance tick counter on the CPU may be slightly out of agreement with the windows clock. Furthermore, the tick counter is probably lots faster to retrieve since it is already updated, and needn't be recalculated each time. (We should consider just switching to millisecond clock resolution internally as well. It turns out that I don't think that timers that are shorter than 1ms are very useful.)
* Fix for valgrind leak.Garrett D'Amore2017-01-06
|
* Bunch of copyright fixes.Garrett D'Amore2017-01-06
|
* Message API was awkward.Garrett D'Amore2017-01-06
| | | | | | | The use of a single function to get both size and length actually turned out to be awkward to use; better to have separate functions to get each. While here, disable some of the initialization/fork checks, because it turns out they aren't needed.
* Add nng_shutdown() for sockets to help avoid close race.Garrett D'Amore2017-01-05
| | | | Also we added a two phase shutdown for threads.
* Send and receive now work.Garrett D'Amore2016-12-27
| | | | | | This fixes a few core issues, and improves readability for the message queue code as well. inproc delivery of messages works now.