diff --git a/deps/zmq/COPYING b/deps/zmq/COPYING deleted file mode 100644 index b6f3fd5d30b..00000000000 --- a/deps/zmq/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/deps/zmq/COPYING.LESSER b/deps/zmq/COPYING.LESSER deleted file mode 100644 index 74aad7919e5..00000000000 --- a/deps/zmq/COPYING.LESSER +++ /dev/null @@ -1,181 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. - --------------------------------------------------------------------------------- - - SPECIAL EXCEPTION GRANTED BY COPYRIGHT HOLDERS - -As a special exception, copyright holders give you permission to link this -library with independent modules to produce an executable, regardless of -the license terms of these independent modules, and to copy and distribute -the resulting executable under terms of your choice, provided that you also -meet, for each linked independent module, the terms and conditions of -the license of that module. An independent module is a module which is not -derived from or based on this library. If you modify this library, you must -extend this exception to your version of the library. - -Note: this exception relieves you of any obligations under sections 4 and 5 -of this license, and section 6 of the GNU General Public License. diff --git a/deps/zmq/LICENSE b/deps/zmq/LICENSE new file mode 100644 index 00000000000..a612ad9813b --- /dev/null +++ b/deps/zmq/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/deps/zmq/external/wepoll/license.txt b/deps/zmq/external/wepoll/license.txt index 31ad7c22931..d7fc4b11705 100644 --- a/deps/zmq/external/wepoll/license.txt +++ b/deps/zmq/external/wepoll/license.txt @@ -1,7 +1,7 @@ wepoll - epoll for Windows https://github.com/piscisaureus/wepoll -Copyright 2012-2018, Bert Belder +Copyright 2012-2020, Bert Belder All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/deps/zmq/external/wepoll/version.txt b/deps/zmq/external/wepoll/version.txt index 62915844245..3b296081e89 100644 --- a/deps/zmq/external/wepoll/version.txt +++ b/deps/zmq/external/wepoll/version.txt @@ -1 +1 @@ -https://github.com/piscisaureus/wepoll/tree/v1.5.4 +https://github.com/piscisaureus/wepoll/tree/v1.5.8 diff --git a/deps/zmq/external/wepoll/wepoll.c b/deps/zmq/external/wepoll/wepoll.c index 3d30141071a..186d3f2d485 100644 --- a/deps/zmq/external/wepoll/wepoll.c +++ b/deps/zmq/external/wepoll/wepoll.c @@ -2,7 +2,7 @@ * wepoll - epoll for Windows * https://github.com/piscisaureus/wepoll * - * Copyright 2012-2018, Bert Belder + * Copyright 2012-2020, Bert Belder * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,8 +35,6 @@ #include -/* clang-format off */ - enum EPOLL_EVENTS { EPOLLIN = (int) (1U << 0), EPOLLPRI = (int) (1U << 1), @@ -69,8 +67,6 @@ enum EPOLL_EVENTS { #define EPOLL_CTL_MOD 2 #define EPOLL_CTL_DEL 3 -/* clang-format on */ - typedef void* HANDLE; typedef uintptr_t SOCKET; @@ -111,40 +107,34 @@ WEPOLL_EXPORT int epoll_wait(HANDLE ephnd, } /* extern "C" */ #endif -#include +#include + #include #define WEPOLL_INTERNAL static -#define WEPOLL_INTERNAL_VAR static +#define WEPOLL_INTERNAL_EXTERN static -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#ifdef __clang__ +#if defined(__clang__) #pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonportable-system-include-path" #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined(_MSC_VER) +#pragma warning(push, 1) #endif -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif +#undef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#undef _WIN32_WINNT #define _WIN32_WINNT 0x0600 -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#ifndef __GNUC__ -#pragma warning(push, 1) -#endif +#include +#include +#include -#include -#include -#include - -#ifndef __GNUC__ +#if defined(__clang__) +#pragma clang diagnostic pop +#elif defined(_MSC_VER) #pragma warning(pop) #endif @@ -169,6 +159,10 @@ typedef NTSTATUS* PNTSTATUS; #define STATUS_CANCELLED ((NTSTATUS) 0xC0000120L) #endif +#ifndef STATUS_NOT_FOUND +#define STATUS_NOT_FOUND ((NTSTATUS) 0xC0000225L) +#endif + typedef struct _IO_STATUS_BLOCK { NTSTATUS Status; ULONG_PTR Information; @@ -178,11 +172,11 @@ typedef VOID(NTAPI* PIO_APC_ROUTINE)(PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved); -typedef struct _LSA_UNICODE_STRING { +typedef struct _UNICODE_STRING { USHORT Length; USHORT MaximumLength; PWSTR Buffer; -} LSA_UNICODE_STRING, *PLSA_UNICODE_STRING, UNICODE_STRING, *PUNICODE_STRING; +} UNICODE_STRING, *PUNICODE_STRING; #define RTL_CONSTANT_STRING(s) \ { sizeof(s) - sizeof((s)[0]), sizeof(s), s } @@ -203,83 +197,79 @@ typedef struct _OBJECT_ATTRIBUTES { #define FILE_OPEN 0x00000001UL #endif -#define NT_NTDLL_IMPORT_LIST(X) \ - X(NTSTATUS, \ - NTAPI, \ - NtCreateFile, \ - (PHANDLE FileHandle, \ - ACCESS_MASK DesiredAccess, \ - POBJECT_ATTRIBUTES ObjectAttributes, \ - PIO_STATUS_BLOCK IoStatusBlock, \ - PLARGE_INTEGER AllocationSize, \ - ULONG FileAttributes, \ - ULONG ShareAccess, \ - ULONG CreateDisposition, \ - ULONG CreateOptions, \ - PVOID EaBuffer, \ - ULONG EaLength)) \ - \ - X(NTSTATUS, \ - NTAPI, \ - NtDeviceIoControlFile, \ - (HANDLE FileHandle, \ - HANDLE Event, \ - PIO_APC_ROUTINE ApcRoutine, \ - PVOID ApcContext, \ - PIO_STATUS_BLOCK IoStatusBlock, \ - ULONG IoControlCode, \ - PVOID InputBuffer, \ - ULONG InputBufferLength, \ - PVOID OutputBuffer, \ - ULONG OutputBufferLength)) \ - \ - X(ULONG, WINAPI, RtlNtStatusToDosError, (NTSTATUS Status)) \ - \ - X(NTSTATUS, \ - NTAPI, \ - NtCreateKeyedEvent, \ - (PHANDLE handle, \ - ACCESS_MASK access, \ - POBJECT_ATTRIBUTES attr, \ - ULONG flags)) \ - \ - X(NTSTATUS, \ - NTAPI, \ - NtWaitForKeyedEvent, \ - (HANDLE handle, PVOID key, BOOLEAN alertable, PLARGE_INTEGER mstimeout)) \ - \ - X(NTSTATUS, \ - NTAPI, \ - NtReleaseKeyedEvent, \ - (HANDLE handle, PVOID key, BOOLEAN alertable, PLARGE_INTEGER mstimeout)) +#define KEYEDEVENT_WAIT 0x00000001UL +#define KEYEDEVENT_WAKE 0x00000002UL +#define KEYEDEVENT_ALL_ACCESS \ + (STANDARD_RIGHTS_REQUIRED | KEYEDEVENT_WAIT | KEYEDEVENT_WAKE) + +#define NT_NTDLL_IMPORT_LIST(X) \ + X(NTSTATUS, \ + NTAPI, \ + NtCancelIoFileEx, \ + (HANDLE FileHandle, \ + PIO_STATUS_BLOCK IoRequestToCancel, \ + PIO_STATUS_BLOCK IoStatusBlock)) \ + \ + X(NTSTATUS, \ + NTAPI, \ + NtCreateFile, \ + (PHANDLE FileHandle, \ + ACCESS_MASK DesiredAccess, \ + POBJECT_ATTRIBUTES ObjectAttributes, \ + PIO_STATUS_BLOCK IoStatusBlock, \ + PLARGE_INTEGER AllocationSize, \ + ULONG FileAttributes, \ + ULONG ShareAccess, \ + ULONG CreateDisposition, \ + ULONG CreateOptions, \ + PVOID EaBuffer, \ + ULONG EaLength)) \ + \ + X(NTSTATUS, \ + NTAPI, \ + NtCreateKeyedEvent, \ + (PHANDLE KeyedEventHandle, \ + ACCESS_MASK DesiredAccess, \ + POBJECT_ATTRIBUTES ObjectAttributes, \ + ULONG Flags)) \ + \ + X(NTSTATUS, \ + NTAPI, \ + NtDeviceIoControlFile, \ + (HANDLE FileHandle, \ + HANDLE Event, \ + PIO_APC_ROUTINE ApcRoutine, \ + PVOID ApcContext, \ + PIO_STATUS_BLOCK IoStatusBlock, \ + ULONG IoControlCode, \ + PVOID InputBuffer, \ + ULONG InputBufferLength, \ + PVOID OutputBuffer, \ + ULONG OutputBufferLength)) \ + \ + X(NTSTATUS, \ + NTAPI, \ + NtReleaseKeyedEvent, \ + (HANDLE KeyedEventHandle, \ + PVOID KeyValue, \ + BOOLEAN Alertable, \ + PLARGE_INTEGER Timeout)) \ + \ + X(NTSTATUS, \ + NTAPI, \ + NtWaitForKeyedEvent, \ + (HANDLE KeyedEventHandle, \ + PVOID KeyValue, \ + BOOLEAN Alertable, \ + PLARGE_INTEGER Timeout)) \ + \ + X(ULONG, WINAPI, RtlNtStatusToDosError, (NTSTATUS Status)) #define X(return_type, attributes, name, parameters) \ - WEPOLL_INTERNAL_VAR return_type(attributes* name) parameters; + WEPOLL_INTERNAL_EXTERN return_type(attributes* name) parameters; NT_NTDLL_IMPORT_LIST(X) #undef X -#include -#include - -#ifndef _SSIZE_T_DEFINED -typedef intptr_t ssize_t; -#endif - -#define array_count(a) (sizeof(a) / (sizeof((a)[0]))) - -/* clang-format off */ -#define container_of(ptr, type, member) \ - ((type*) ((uintptr_t) (ptr) - offsetof(type, member))) -/* clang-format on */ - -#define unused_var(v) ((void) (v)) - -/* Polyfill `inline` for older versions of msvc (up to Visual Studio 2013) */ -#if defined(_MSC_VER) && _MSC_VER < 1900 -#define inline __inline -#endif - -/* clang-format off */ #define AFD_POLL_RECEIVE 0x0001 #define AFD_POLL_RECEIVE_EXPEDITED 0x0002 #define AFD_POLL_SEND 0x0004 @@ -288,7 +278,6 @@ typedef intptr_t ssize_t; #define AFD_POLL_LOCAL_CLOSE 0x0020 #define AFD_POLL_ACCEPT 0x0080 #define AFD_POLL_CONNECT_FAIL 0x0100 -/* clang-format on */ typedef struct _AFD_POLL_HANDLE_INFO { HANDLE Handle; @@ -303,12 +292,14 @@ typedef struct _AFD_POLL_INFO { AFD_POLL_HANDLE_INFO Handles[1]; } AFD_POLL_INFO, *PAFD_POLL_INFO; -WEPOLL_INTERNAL int afd_create_helper_handle(HANDLE iocp, - HANDLE* afd_helper_handle_out); +WEPOLL_INTERNAL int afd_create_device_handle(HANDLE iocp_handle, + HANDLE* afd_device_handle_out); -WEPOLL_INTERNAL int afd_poll(HANDLE afd_helper_handle, +WEPOLL_INTERNAL int afd_poll(HANDLE afd_device_handle, AFD_POLL_INFO* poll_info, - OVERLAPPED* overlapped); + IO_STATUS_BLOCK* io_status_block); +WEPOLL_INTERNAL int afd_cancel_poll(HANDLE afd_device_handle, + IO_STATUS_BLOCK* io_status_block); #define return_map_error(value) \ do { \ @@ -326,28 +317,26 @@ WEPOLL_INTERNAL void err_map_win_error(void); WEPOLL_INTERNAL void err_set_win_error(DWORD error); WEPOLL_INTERNAL int err_check_handle(HANDLE handle); -WEPOLL_INTERNAL int ws_global_init(void); -WEPOLL_INTERNAL SOCKET ws_get_base_socket(SOCKET socket); - #define IOCTL_AFD_POLL 0x00012024 -static UNICODE_STRING afd__helper_name = +static UNICODE_STRING afd__device_name = RTL_CONSTANT_STRING(L"\\Device\\Afd\\Wepoll"); -static OBJECT_ATTRIBUTES afd__helper_attributes = - RTL_CONSTANT_OBJECT_ATTRIBUTES(&afd__helper_name, 0); +static OBJECT_ATTRIBUTES afd__device_attributes = + RTL_CONSTANT_OBJECT_ATTRIBUTES(&afd__device_name, 0); -int afd_create_helper_handle(HANDLE iocp, HANDLE* afd_helper_handle_out) { - HANDLE afd_helper_handle; +int afd_create_device_handle(HANDLE iocp_handle, + HANDLE* afd_device_handle_out) { + HANDLE afd_device_handle; IO_STATUS_BLOCK iosb; NTSTATUS status; /* By opening \Device\Afd without specifying any extended attributes, we'll * get a handle that lets us talk to the AFD driver, but that doesn't have an * associated endpoint (so it's not a socket). */ - status = NtCreateFile(&afd_helper_handle, + status = NtCreateFile(&afd_device_handle, SYNCHRONIZE, - &afd__helper_attributes, + &afd__device_attributes, &iosb, NULL, 0, @@ -359,50 +348,35 @@ int afd_create_helper_handle(HANDLE iocp, HANDLE* afd_helper_handle_out) { if (status != STATUS_SUCCESS) return_set_error(-1, RtlNtStatusToDosError(status)); - if (CreateIoCompletionPort(afd_helper_handle, iocp, 0, 0) == NULL) + if (CreateIoCompletionPort(afd_device_handle, iocp_handle, 0, 0) == NULL) goto error; - if (!SetFileCompletionNotificationModes(afd_helper_handle, + if (!SetFileCompletionNotificationModes(afd_device_handle, FILE_SKIP_SET_EVENT_ON_HANDLE)) goto error; - *afd_helper_handle_out = afd_helper_handle; + *afd_device_handle_out = afd_device_handle; return 0; error: - CloseHandle(afd_helper_handle); + CloseHandle(afd_device_handle); return_map_error(-1); } -int afd_poll(HANDLE afd_helper_handle, +int afd_poll(HANDLE afd_device_handle, AFD_POLL_INFO* poll_info, - OVERLAPPED* overlapped) { - IO_STATUS_BLOCK* iosb; - HANDLE event; - void* apc_context; + IO_STATUS_BLOCK* io_status_block) { NTSTATUS status; /* Blocking operation is not supported. */ - assert(overlapped != NULL); - - iosb = (IO_STATUS_BLOCK*) &overlapped->Internal; - event = overlapped->hEvent; - - /* Do what other windows APIs would do: if hEvent has it's lowest bit set, - * don't post a completion to the completion port. */ - if ((uintptr_t) event & 1) { - event = (HANDLE)((uintptr_t) event & ~(uintptr_t) 1); - apc_context = NULL; - } else { - apc_context = overlapped; - } + assert(io_status_block != NULL); - iosb->Status = STATUS_PENDING; - status = NtDeviceIoControlFile(afd_helper_handle, - event, + io_status_block->Status = STATUS_PENDING; + status = NtDeviceIoControlFile(afd_device_handle, + NULL, NULL, - apc_context, - iosb, + io_status_block, + io_status_block, IOCTL_AFD_POLL, poll_info, sizeof *poll_info, @@ -417,106 +391,75 @@ int afd_poll(HANDLE afd_helper_handle, return_set_error(-1, RtlNtStatusToDosError(status)); } -WEPOLL_INTERNAL int epoll_global_init(void); - -WEPOLL_INTERNAL int init(void); - -#include - -typedef struct queue_node queue_node_t; - -typedef struct queue_node { - queue_node_t* prev; - queue_node_t* next; -} queue_node_t; +int afd_cancel_poll(HANDLE afd_device_handle, + IO_STATUS_BLOCK* io_status_block) { + NTSTATUS cancel_status; + IO_STATUS_BLOCK cancel_iosb; -typedef struct queue { - queue_node_t head; -} queue_t; + /* If the poll operation has already completed or has been cancelled earlier, + * there's nothing left for us to do. */ + if (io_status_block->Status != STATUS_PENDING) + return 0; -WEPOLL_INTERNAL void queue_init(queue_t* queue); -WEPOLL_INTERNAL void queue_node_init(queue_node_t* node); + cancel_status = + NtCancelIoFileEx(afd_device_handle, io_status_block, &cancel_iosb); -WEPOLL_INTERNAL queue_node_t* queue_first(const queue_t* queue); -WEPOLL_INTERNAL queue_node_t* queue_last(const queue_t* queue); + /* NtCancelIoFileEx() may return STATUS_NOT_FOUND if the operation completed + * just before calling NtCancelIoFileEx(). This is not an error. */ + if (cancel_status == STATUS_SUCCESS || cancel_status == STATUS_NOT_FOUND) + return 0; + else + return_set_error(-1, RtlNtStatusToDosError(cancel_status)); +} -WEPOLL_INTERNAL void queue_prepend(queue_t* queue, queue_node_t* node); -WEPOLL_INTERNAL void queue_append(queue_t* queue, queue_node_t* node); -WEPOLL_INTERNAL void queue_move_first(queue_t* queue, queue_node_t* node); -WEPOLL_INTERNAL void queue_move_last(queue_t* queue, queue_node_t* node); -WEPOLL_INTERNAL void queue_remove(queue_node_t* node); +WEPOLL_INTERNAL int epoll_global_init(void); -WEPOLL_INTERNAL bool queue_empty(const queue_t* queue); -WEPOLL_INTERNAL bool queue_enqueued(const queue_node_t* node); +WEPOLL_INTERNAL int init(void); typedef struct port_state port_state_t; -typedef struct poll_group poll_group_t; - -WEPOLL_INTERNAL poll_group_t* poll_group_acquire(port_state_t* port); -WEPOLL_INTERNAL void poll_group_release(poll_group_t* poll_group); - -WEPOLL_INTERNAL void poll_group_delete(poll_group_t* poll_group); - -WEPOLL_INTERNAL poll_group_t* poll_group_from_queue_node( - queue_node_t* queue_node); -WEPOLL_INTERNAL HANDLE - poll_group_get_afd_helper_handle(poll_group_t* poll_group); - -/* N.b.: the tree functions do not set errno or LastError when they fail. Each - * of the API functions has at most one failure mode. It is up to the caller to - * set an appropriate error code when necessary. */ - -typedef struct tree tree_t; -typedef struct tree_node tree_node_t; - -typedef struct tree { - tree_node_t* root; -} tree_t; - -typedef struct tree_node { - tree_node_t* left; - tree_node_t* right; - tree_node_t* parent; - uintptr_t key; - bool red; -} tree_node_t; +typedef struct queue queue_t; +typedef struct sock_state sock_state_t; +typedef struct ts_tree_node ts_tree_node_t; -WEPOLL_INTERNAL void tree_init(tree_t* tree); -WEPOLL_INTERNAL void tree_node_init(tree_node_t* node); +WEPOLL_INTERNAL port_state_t* port_new(HANDLE* iocp_handle_out); +WEPOLL_INTERNAL int port_close(port_state_t* port_state); +WEPOLL_INTERNAL int port_delete(port_state_t* port_state); -WEPOLL_INTERNAL int tree_add(tree_t* tree, tree_node_t* node, uintptr_t key); -WEPOLL_INTERNAL void tree_del(tree_t* tree, tree_node_t* node); +WEPOLL_INTERNAL int port_wait(port_state_t* port_state, + struct epoll_event* events, + int maxevents, + int timeout); -WEPOLL_INTERNAL tree_node_t* tree_find(const tree_t* tree, uintptr_t key); -WEPOLL_INTERNAL tree_node_t* tree_root(const tree_t* tree); +WEPOLL_INTERNAL int port_ctl(port_state_t* port_state, + int op, + SOCKET sock, + struct epoll_event* ev); -typedef struct port_state port_state_t; -typedef struct sock_state sock_state_t; +WEPOLL_INTERNAL int port_register_socket(port_state_t* port_state, + sock_state_t* sock_state, + SOCKET socket); +WEPOLL_INTERNAL void port_unregister_socket(port_state_t* port_state, + sock_state_t* sock_state); +WEPOLL_INTERNAL sock_state_t* port_find_socket(port_state_t* port_state, + SOCKET socket); -WEPOLL_INTERNAL sock_state_t* sock_new(port_state_t* port_state, - SOCKET socket); -WEPOLL_INTERNAL void sock_delete(port_state_t* port_state, - sock_state_t* sock_state); -WEPOLL_INTERNAL void sock_force_delete(port_state_t* port_state, - sock_state_t* sock_state); +WEPOLL_INTERNAL void port_request_socket_update(port_state_t* port_state, + sock_state_t* sock_state); +WEPOLL_INTERNAL void port_cancel_socket_update(port_state_t* port_state, + sock_state_t* sock_state); -WEPOLL_INTERNAL int sock_set_event(port_state_t* port_state, - sock_state_t* sock_state, - const struct epoll_event* ev); +WEPOLL_INTERNAL void port_add_deleted_socket(port_state_t* port_state, + sock_state_t* sock_state); +WEPOLL_INTERNAL void port_remove_deleted_socket(port_state_t* port_state, + sock_state_t* sock_state); -WEPOLL_INTERNAL int sock_update(port_state_t* port_state, - sock_state_t* sock_state); -WEPOLL_INTERNAL int sock_feed_event(port_state_t* port_state, - OVERLAPPED* overlapped, - struct epoll_event* ev); +WEPOLL_INTERNAL HANDLE port_get_iocp_handle(port_state_t* port_state); +WEPOLL_INTERNAL queue_t* port_get_poll_group_queue(port_state_t* port_state); -WEPOLL_INTERNAL sock_state_t* sock_state_from_queue_node( - queue_node_t* queue_node); -WEPOLL_INTERNAL queue_node_t* sock_state_to_queue_node( - sock_state_t* sock_state); -WEPOLL_INTERNAL sock_state_t* sock_state_from_tree_node( - tree_node_t* tree_node); -WEPOLL_INTERNAL tree_node_t* sock_state_to_tree_node(sock_state_t* sock_state); +WEPOLL_INTERNAL port_state_t* port_state_from_handle_tree_node( + ts_tree_node_t* tree_node); +WEPOLL_INTERNAL ts_tree_node_t* port_state_to_handle_tree_node( + port_state_t* port_state); /* The reflock is a special kind of lock that normally prevents a chunk of * memory from being freed, but does allow the chunk of memory to eventually be @@ -547,6 +490,36 @@ WEPOLL_INTERNAL void reflock_ref(reflock_t* reflock); WEPOLL_INTERNAL void reflock_unref(reflock_t* reflock); WEPOLL_INTERNAL void reflock_unref_and_destroy(reflock_t* reflock); +#include + +/* N.b.: the tree functions do not set errno or LastError when they fail. Each + * of the API functions has at most one failure mode. It is up to the caller to + * set an appropriate error code when necessary. */ + +typedef struct tree tree_t; +typedef struct tree_node tree_node_t; + +typedef struct tree { + tree_node_t* root; +} tree_t; + +typedef struct tree_node { + tree_node_t* left; + tree_node_t* right; + tree_node_t* parent; + uintptr_t key; + bool red; +} tree_node_t; + +WEPOLL_INTERNAL void tree_init(tree_t* tree); +WEPOLL_INTERNAL void tree_node_init(tree_node_t* node); + +WEPOLL_INTERNAL int tree_add(tree_t* tree, tree_node_t* node, uintptr_t key); +WEPOLL_INTERNAL void tree_del(tree_t* tree, tree_node_t* node); + +WEPOLL_INTERNAL tree_node_t* tree_find(const tree_t* tree, uintptr_t key); +WEPOLL_INTERNAL tree_node_t* tree_root(const tree_t* tree); + typedef struct ts_tree { tree_t tree; SRWLOCK lock; @@ -572,59 +545,8 @@ WEPOLL_INTERNAL ts_tree_node_t* ts_tree_find_and_ref(ts_tree_t* ts_tree, WEPOLL_INTERNAL void ts_tree_node_unref(ts_tree_node_t* node); WEPOLL_INTERNAL void ts_tree_node_unref_and_destroy(ts_tree_node_t* node); -typedef struct port_state port_state_t; -typedef struct sock_state sock_state_t; - -typedef struct port_state { - HANDLE iocp; - tree_t sock_tree; - queue_t sock_update_queue; - queue_t sock_deleted_queue; - queue_t poll_group_queue; - ts_tree_node_t handle_tree_node; - CRITICAL_SECTION lock; - size_t active_poll_count; -} port_state_t; - -WEPOLL_INTERNAL port_state_t* port_new(HANDLE* iocp_out); -WEPOLL_INTERNAL int port_close(port_state_t* port_state); -WEPOLL_INTERNAL int port_delete(port_state_t* port_state); - -WEPOLL_INTERNAL int port_wait(port_state_t* port_state, - struct epoll_event* events, - int maxevents, - int timeout); - -WEPOLL_INTERNAL int port_ctl(port_state_t* port_state, - int op, - SOCKET sock, - struct epoll_event* ev); - -WEPOLL_INTERNAL int port_register_socket_handle(port_state_t* port_state, - sock_state_t* sock_state, - SOCKET socket); -WEPOLL_INTERNAL void port_unregister_socket_handle(port_state_t* port_state, - sock_state_t* sock_state); -WEPOLL_INTERNAL sock_state_t* port_find_socket(port_state_t* port_state, - SOCKET socket); - -WEPOLL_INTERNAL void port_request_socket_update(port_state_t* port_state, - sock_state_t* sock_state); -WEPOLL_INTERNAL void port_cancel_socket_update(port_state_t* port_state, - sock_state_t* sock_state); - -WEPOLL_INTERNAL void port_add_deleted_socket(port_state_t* port_state, - sock_state_t* sock_state); -WEPOLL_INTERNAL void port_remove_deleted_socket(port_state_t* port_state, - sock_state_t* sock_state); - static ts_tree_t epoll__handle_tree; -static inline port_state_t* epoll__handle_tree_node_to_port( - ts_tree_node_t* tree_node) { - return container_of(tree_node, port_state_t, handle_tree_node); -} - int epoll_global_init(void) { ts_tree_init(&epoll__handle_tree); return 0; @@ -633,6 +555,7 @@ int epoll_global_init(void) { static HANDLE epoll__create(void) { port_state_t* port_state; HANDLE ephnd; + ts_tree_node_t* tree_node; if (init() < 0) return NULL; @@ -641,9 +564,8 @@ static HANDLE epoll__create(void) { if (port_state == NULL) return NULL; - if (ts_tree_add(&epoll__handle_tree, - &port_state->handle_tree_node, - (uintptr_t) ephnd) < 0) { + tree_node = port_state_to_handle_tree_node(port_state); + if (ts_tree_add(&epoll__handle_tree, tree_node, (uintptr_t) ephnd) < 0) { /* This should never happen. */ port_delete(port_state); return_set_error(NULL, ERROR_ALREADY_EXISTS); @@ -679,7 +601,7 @@ int epoll_close(HANDLE ephnd) { goto err; } - port_state = epoll__handle_tree_node_to_port(tree_node); + port_state = port_state_from_handle_tree_node(tree_node); port_close(port_state); ts_tree_node_unref_and_destroy(tree_node); @@ -705,7 +627,7 @@ int epoll_ctl(HANDLE ephnd, int op, SOCKET sock, struct epoll_event* ev) { goto err; } - port_state = epoll__handle_tree_node_to_port(tree_node); + port_state = port_state_from_handle_tree_node(tree_node); r = port_ctl(port_state, op, sock, ev); ts_tree_node_unref(tree_node); @@ -716,7 +638,7 @@ int epoll_ctl(HANDLE ephnd, int op, SOCKET sock, struct epoll_event* ev) { return 0; err: - /* On Linux, in the case of epoll_ctl_mod(), EBADF takes priority over other + /* On Linux, in the case of epoll_ctl(), EBADF takes priority over other * errors. Wepoll mimics this behavior. */ err_check_handle(ephnd); err_check_handle((HANDLE) sock); @@ -743,7 +665,7 @@ int epoll_wait(HANDLE ephnd, goto err; } - port_state = epoll__handle_tree_node_to_port(tree_node); + port_state = port_state_from_handle_tree_node(tree_node); num_events = port_wait(port_state, events, maxevents, timeout); ts_tree_node_unref(tree_node); @@ -897,6 +819,23 @@ int err_check_handle(HANDLE handle) { return 0; } +#include + +#define array_count(a) (sizeof(a) / (sizeof((a)[0]))) + +#define container_of(ptr, type, member) \ + ((type*) ((uintptr_t) (ptr) - offsetof(type, member))) + +#define unused_var(v) ((void) (v)) + +/* Polyfill `inline` for older versions of msvc (up to Visual Studio 2013) */ +#if defined(_MSC_VER) && _MSC_VER < 1900 +#define inline __inline +#endif + +WEPOLL_INTERNAL int ws_global_init(void); +WEPOLL_INTERNAL SOCKET ws_get_base_socket(SOCKET socket); + static bool init__done = false; static INIT_ONCE init__once = INIT_ONCE_STATIC_INIT; @@ -919,7 +858,11 @@ static BOOL CALLBACK init__once_callback(INIT_ONCE* once, int init(void) { if (!init__done && !InitOnceExecuteOnce(&init__once, init__once_callback, NULL, NULL)) - return -1; /* LastError and errno aren't touched InitOnceExecuteOnce. */ + /* `InitOnceExecuteOnce()` itself is infallible, and it doesn't set any + * error code when the once-callback returns FALSE. We return -1 here to + * indicate that global initialization failed; the failing init function is + * resposible for setting `errno` and calling `SetLastError()`. */ + return -1; return 0; } @@ -962,16 +905,57 @@ int nt_global_init(void) { #include -static const size_t POLL_GROUP__MAX_GROUP_SIZE = 32; +typedef struct poll_group poll_group_t; + +typedef struct queue_node queue_node_t; + +WEPOLL_INTERNAL poll_group_t* poll_group_acquire(port_state_t* port); +WEPOLL_INTERNAL void poll_group_release(poll_group_t* poll_group); + +WEPOLL_INTERNAL void poll_group_delete(poll_group_t* poll_group); + +WEPOLL_INTERNAL poll_group_t* poll_group_from_queue_node( + queue_node_t* queue_node); +WEPOLL_INTERNAL HANDLE + poll_group_get_afd_device_handle(poll_group_t* poll_group); + +typedef struct queue_node { + queue_node_t* prev; + queue_node_t* next; +} queue_node_t; + +typedef struct queue { + queue_node_t head; +} queue_t; + +WEPOLL_INTERNAL void queue_init(queue_t* queue); +WEPOLL_INTERNAL void queue_node_init(queue_node_t* node); + +WEPOLL_INTERNAL queue_node_t* queue_first(const queue_t* queue); +WEPOLL_INTERNAL queue_node_t* queue_last(const queue_t* queue); + +WEPOLL_INTERNAL void queue_prepend(queue_t* queue, queue_node_t* node); +WEPOLL_INTERNAL void queue_append(queue_t* queue, queue_node_t* node); +WEPOLL_INTERNAL void queue_move_to_start(queue_t* queue, queue_node_t* node); +WEPOLL_INTERNAL void queue_move_to_end(queue_t* queue, queue_node_t* node); +WEPOLL_INTERNAL void queue_remove(queue_node_t* node); + +WEPOLL_INTERNAL bool queue_is_empty(const queue_t* queue); +WEPOLL_INTERNAL bool queue_is_enqueued(const queue_node_t* node); + +#define POLL_GROUP__MAX_GROUP_SIZE 32 typedef struct poll_group { port_state_t* port_state; queue_node_t queue_node; - HANDLE afd_helper_handle; + HANDLE afd_device_handle; size_t group_size; } poll_group_t; static poll_group_t* poll_group__new(port_state_t* port_state) { + HANDLE iocp_handle = port_get_iocp_handle(port_state); + queue_t* poll_group_queue = port_get_poll_group_queue(port_state); + poll_group_t* poll_group = malloc(sizeof *poll_group); if (poll_group == NULL) return_set_error(NULL, ERROR_NOT_ENOUGH_MEMORY); @@ -981,20 +965,20 @@ static poll_group_t* poll_group__new(port_state_t* port_state) { queue_node_init(&poll_group->queue_node); poll_group->port_state = port_state; - if (afd_create_helper_handle(port_state->iocp, - &poll_group->afd_helper_handle) < 0) { + if (afd_create_device_handle(iocp_handle, &poll_group->afd_device_handle) < + 0) { free(poll_group); return NULL; } - queue_append(&port_state->poll_group_queue, &poll_group->queue_node); + queue_append(poll_group_queue, &poll_group->queue_node); return poll_group; } void poll_group_delete(poll_group_t* poll_group) { assert(poll_group->group_size == 0); - CloseHandle(poll_group->afd_helper_handle); + CloseHandle(poll_group->afd_device_handle); queue_remove(&poll_group->queue_node); free(poll_group); } @@ -1003,15 +987,16 @@ poll_group_t* poll_group_from_queue_node(queue_node_t* queue_node) { return container_of(queue_node, poll_group_t, queue_node); } -HANDLE poll_group_get_afd_helper_handle(poll_group_t* poll_group) { - return poll_group->afd_helper_handle; +HANDLE poll_group_get_afd_device_handle(poll_group_t* poll_group) { + return poll_group->afd_device_handle; } poll_group_t* poll_group_acquire(port_state_t* port_state) { - queue_t* queue = &port_state->poll_group_queue; + queue_t* poll_group_queue = port_get_poll_group_queue(port_state); poll_group_t* poll_group = - !queue_empty(queue) - ? container_of(queue_last(queue), poll_group_t, queue_node) + !queue_is_empty(poll_group_queue) + ? container_of( + queue_last(poll_group_queue), poll_group_t, queue_node) : NULL; if (poll_group == NULL || @@ -1021,25 +1006,62 @@ poll_group_t* poll_group_acquire(port_state_t* port_state) { return NULL; if (++poll_group->group_size == POLL_GROUP__MAX_GROUP_SIZE) - queue_move_first(&port_state->poll_group_queue, &poll_group->queue_node); + queue_move_to_start(poll_group_queue, &poll_group->queue_node); return poll_group; } void poll_group_release(poll_group_t* poll_group) { port_state_t* port_state = poll_group->port_state; + queue_t* poll_group_queue = port_get_poll_group_queue(port_state); poll_group->group_size--; assert(poll_group->group_size < POLL_GROUP__MAX_GROUP_SIZE); - queue_move_last(&port_state->poll_group_queue, &poll_group->queue_node); + queue_move_to_end(poll_group_queue, &poll_group->queue_node); /* Poll groups are currently only freed when the epoll port is closed. */ } +WEPOLL_INTERNAL sock_state_t* sock_new(port_state_t* port_state, + SOCKET socket); +WEPOLL_INTERNAL void sock_delete(port_state_t* port_state, + sock_state_t* sock_state); +WEPOLL_INTERNAL void sock_force_delete(port_state_t* port_state, + sock_state_t* sock_state); + +WEPOLL_INTERNAL int sock_set_event(port_state_t* port_state, + sock_state_t* sock_state, + const struct epoll_event* ev); + +WEPOLL_INTERNAL int sock_update(port_state_t* port_state, + sock_state_t* sock_state); +WEPOLL_INTERNAL int sock_feed_event(port_state_t* port_state, + IO_STATUS_BLOCK* io_status_block, + struct epoll_event* ev); + +WEPOLL_INTERNAL sock_state_t* sock_state_from_queue_node( + queue_node_t* queue_node); +WEPOLL_INTERNAL queue_node_t* sock_state_to_queue_node( + sock_state_t* sock_state); +WEPOLL_INTERNAL sock_state_t* sock_state_from_tree_node( + tree_node_t* tree_node); +WEPOLL_INTERNAL tree_node_t* sock_state_to_tree_node(sock_state_t* sock_state); + #define PORT__MAX_ON_STACK_COMPLETIONS 256 -static port_state_t* port__alloc(void) { +typedef struct port_state { + HANDLE iocp_handle; + tree_t sock_tree; + queue_t sock_update_queue; + queue_t sock_deleted_queue; + queue_t poll_group_queue; + ts_tree_node_t handle_tree_node; + CRITICAL_SECTION lock; + size_t active_poll_count; +} port_state_t; + +static inline port_state_t* port__alloc(void) { port_state_t* port_state = malloc(sizeof *port_state); if (port_state == NULL) return_set_error(NULL, ERROR_NOT_ENOUGH_MEMORY); @@ -1047,34 +1069,35 @@ static port_state_t* port__alloc(void) { return port_state; } -static void port__free(port_state_t* port) { +static inline void port__free(port_state_t* port) { assert(port != NULL); free(port); } -static HANDLE port__create_iocp(void) { - HANDLE iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0); - if (iocp == NULL) +static inline HANDLE port__create_iocp(void) { + HANDLE iocp_handle = + CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0); + if (iocp_handle == NULL) return_map_error(NULL); - return iocp; + return iocp_handle; } -port_state_t* port_new(HANDLE* iocp_out) { +port_state_t* port_new(HANDLE* iocp_handle_out) { port_state_t* port_state; - HANDLE iocp; + HANDLE iocp_handle; port_state = port__alloc(); if (port_state == NULL) goto err1; - iocp = port__create_iocp(); - if (iocp == NULL) + iocp_handle = port__create_iocp(); + if (iocp_handle == NULL) goto err2; memset(port_state, 0, sizeof *port_state); - port_state->iocp = iocp; + port_state->iocp_handle = iocp_handle; tree_init(&port_state->sock_tree); queue_init(&port_state->sock_update_queue); queue_init(&port_state->sock_deleted_queue); @@ -1082,7 +1105,7 @@ port_state_t* port_new(HANDLE* iocp_out) { ts_tree_node_init(&port_state->handle_tree_node); InitializeCriticalSection(&port_state->lock); - *iocp_out = iocp; + *iocp_handle_out = iocp_handle; return port_state; err2: @@ -1091,11 +1114,11 @@ port_state_t* port_new(HANDLE* iocp_out) { return NULL; } -static int port__close_iocp(port_state_t* port_state) { - HANDLE iocp = port_state->iocp; - port_state->iocp = NULL; +static inline int port__close_iocp(port_state_t* port_state) { + HANDLE iocp_handle = port_state->iocp_handle; + port_state->iocp_handle = NULL; - if (!CloseHandle(iocp)) + if (!CloseHandle(iocp_handle)) return_map_error(-1); return 0; @@ -1116,7 +1139,7 @@ int port_delete(port_state_t* port_state) { queue_node_t* queue_node; /* At this point the IOCP port should have been closed. */ - assert(port_state->iocp == NULL); + assert(port_state->iocp_handle == NULL); while ((tree_node = tree_root(&port_state->sock_tree)) != NULL) { sock_state_t* sock_state = sock_state_from_tree_node(tree_node); @@ -1133,7 +1156,7 @@ int port_delete(port_state_t* port_state) { poll_group_delete(poll_group); } - assert(queue_empty(&port_state->sock_update_queue)); + assert(queue_is_empty(&port_state->sock_update_queue)); DeleteCriticalSection(&port_state->lock); @@ -1147,7 +1170,7 @@ static int port__update_events(port_state_t* port_state) { /* Walk the queue, submitting new poll requests for every socket that needs * it. */ - while (!queue_empty(sock_update_queue)) { + while (!queue_is_empty(sock_update_queue)) { queue_node_t* queue_node = queue_first(sock_update_queue); sock_state_t* sock_state = sock_state_from_queue_node(queue_node); @@ -1160,33 +1183,34 @@ static int port__update_events(port_state_t* port_state) { return 0; } -static void port__update_events_if_polling(port_state_t* port_state) { +static inline void port__update_events_if_polling(port_state_t* port_state) { if (port_state->active_poll_count > 0) port__update_events(port_state); } -static int port__feed_events(port_state_t* port_state, - struct epoll_event* epoll_events, - OVERLAPPED_ENTRY* iocp_events, - DWORD iocp_event_count) { +static inline int port__feed_events(port_state_t* port_state, + struct epoll_event* epoll_events, + OVERLAPPED_ENTRY* iocp_events, + DWORD iocp_event_count) { int epoll_event_count = 0; DWORD i; for (i = 0; i < iocp_event_count; i++) { - OVERLAPPED* overlapped = iocp_events[i].lpOverlapped; + IO_STATUS_BLOCK* io_status_block = + (IO_STATUS_BLOCK*) iocp_events[i].lpOverlapped; struct epoll_event* ev = &epoll_events[epoll_event_count]; - epoll_event_count += sock_feed_event(port_state, overlapped, ev); + epoll_event_count += sock_feed_event(port_state, io_status_block, ev); } return epoll_event_count; } -static int port__poll(port_state_t* port_state, - struct epoll_event* epoll_events, - OVERLAPPED_ENTRY* iocp_events, - DWORD maxevents, - DWORD timeout) { +static inline int port__poll(port_state_t* port_state, + struct epoll_event* epoll_events, + OVERLAPPED_ENTRY* iocp_events, + DWORD maxevents, + DWORD timeout) { DWORD completion_count; if (port__update_events(port_state) < 0) @@ -1196,7 +1220,7 @@ static int port__poll(port_state_t* port_state, LeaveCriticalSection(&port_state->lock); - BOOL r = GetQueuedCompletionStatusEx(port_state->iocp, + BOOL r = GetQueuedCompletionStatusEx(port_state->iocp_handle, iocp_events, maxevents, &completion_count, @@ -1292,9 +1316,9 @@ int port_wait(port_state_t* port_state, return -1; } -static int port__ctl_add(port_state_t* port_state, - SOCKET sock, - struct epoll_event* ev) { +static inline int port__ctl_add(port_state_t* port_state, + SOCKET sock, + struct epoll_event* ev) { sock_state_t* sock_state = sock_new(port_state, sock); if (sock_state == NULL) return -1; @@ -1309,9 +1333,9 @@ static int port__ctl_add(port_state_t* port_state, return 0; } -static int port__ctl_mod(port_state_t* port_state, - SOCKET sock, - struct epoll_event* ev) { +static inline int port__ctl_mod(port_state_t* port_state, + SOCKET sock, + struct epoll_event* ev) { sock_state_t* sock_state = port_find_socket(port_state, sock); if (sock_state == NULL) return -1; @@ -1324,7 +1348,7 @@ static int port__ctl_mod(port_state_t* port_state, return 0; } -static int port__ctl_del(port_state_t* port_state, SOCKET sock) { +static inline int port__ctl_del(port_state_t* port_state, SOCKET sock) { sock_state_t* sock_state = port_find_socket(port_state, sock); if (sock_state == NULL) return -1; @@ -1334,10 +1358,10 @@ static int port__ctl_del(port_state_t* port_state, SOCKET sock) { return 0; } -static int port__ctl_op(port_state_t* port_state, - int op, - SOCKET sock, - struct epoll_event* ev) { +static inline int port__ctl_op(port_state_t* port_state, + int op, + SOCKET sock, + struct epoll_event* ev) { switch (op) { case EPOLL_CTL_ADD: return port__ctl_add(port_state, sock, ev); @@ -1363,9 +1387,9 @@ int port_ctl(port_state_t* port_state, return result; } -int port_register_socket_handle(port_state_t* port_state, - sock_state_t* sock_state, - SOCKET socket) { +int port_register_socket(port_state_t* port_state, + sock_state_t* sock_state, + SOCKET socket) { if (tree_add(&port_state->sock_tree, sock_state_to_tree_node(sock_state), socket) < 0) @@ -1373,8 +1397,8 @@ int port_register_socket_handle(port_state_t* port_state, return 0; } -void port_unregister_socket_handle(port_state_t* port_state, - sock_state_t* sock_state) { +void port_unregister_socket(port_state_t* port_state, + sock_state_t* sock_state) { tree_del(&port_state->sock_tree, sock_state_to_tree_node(sock_state)); } @@ -1387,7 +1411,7 @@ sock_state_t* port_find_socket(port_state_t* port_state, SOCKET socket) { void port_request_socket_update(port_state_t* port_state, sock_state_t* sock_state) { - if (queue_enqueued(sock_state_to_queue_node(sock_state))) + if (queue_is_enqueued(sock_state_to_queue_node(sock_state))) return; queue_append(&port_state->sock_update_queue, sock_state_to_queue_node(sock_state)); @@ -1396,14 +1420,14 @@ void port_request_socket_update(port_state_t* port_state, void port_cancel_socket_update(port_state_t* port_state, sock_state_t* sock_state) { unused_var(port_state); - if (!queue_enqueued(sock_state_to_queue_node(sock_state))) + if (!queue_is_enqueued(sock_state_to_queue_node(sock_state))) return; queue_remove(sock_state_to_queue_node(sock_state)); } void port_add_deleted_socket(port_state_t* port_state, sock_state_t* sock_state) { - if (queue_enqueued(sock_state_to_queue_node(sock_state))) + if (queue_is_enqueued(sock_state_to_queue_node(sock_state))) return; queue_append(&port_state->sock_deleted_queue, sock_state_to_queue_node(sock_state)); @@ -1412,11 +1436,28 @@ void port_add_deleted_socket(port_state_t* port_state, void port_remove_deleted_socket(port_state_t* port_state, sock_state_t* sock_state) { unused_var(port_state); - if (!queue_enqueued(sock_state_to_queue_node(sock_state))) + if (!queue_is_enqueued(sock_state_to_queue_node(sock_state))) return; queue_remove(sock_state_to_queue_node(sock_state)); } +HANDLE port_get_iocp_handle(port_state_t* port_state) { + assert(port_state->iocp_handle != NULL); + return port_state->iocp_handle; +} + +queue_t* port_get_poll_group_queue(port_state_t* port_state) { + return &port_state->poll_group_queue; +} + +port_state_t* port_state_from_handle_tree_node(ts_tree_node_t* tree_node) { + return container_of(tree_node, port_state_t, handle_tree_node); +} + +ts_tree_node_t* port_state_to_handle_tree_node(port_state_t* port_state) { + return &port_state->handle_tree_node; +} + void queue_init(queue_t* queue) { queue_node_init(&queue->head); } @@ -1432,11 +1473,11 @@ static inline void queue__detach_node(queue_node_t* node) { } queue_node_t* queue_first(const queue_t* queue) { - return !queue_empty(queue) ? queue->head.next : NULL; + return !queue_is_empty(queue) ? queue->head.next : NULL; } queue_node_t* queue_last(const queue_t* queue) { - return !queue_empty(queue) ? queue->head.prev : NULL; + return !queue_is_empty(queue) ? queue->head.prev : NULL; } void queue_prepend(queue_t* queue, queue_node_t* node) { @@ -1453,12 +1494,12 @@ void queue_append(queue_t* queue, queue_node_t* node) { queue->head.prev = node; } -void queue_move_first(queue_t* queue, queue_node_t* node) { +void queue_move_to_start(queue_t* queue, queue_node_t* node) { queue__detach_node(node); queue_prepend(queue, node); } -void queue_move_last(queue_t* queue, queue_node_t* node) { +void queue_move_to_end(queue_t* queue, queue_node_t* node) { queue__detach_node(node); queue_append(queue, node); } @@ -1468,27 +1509,25 @@ void queue_remove(queue_node_t* node) { queue_node_init(node); } -bool queue_empty(const queue_t* queue) { - return !queue_enqueued(&queue->head); +bool queue_is_empty(const queue_t* queue) { + return !queue_is_enqueued(&queue->head); } -bool queue_enqueued(const queue_node_t* node) { +bool queue_is_enqueued(const queue_node_t* node) { return node->prev != node; } -/* clang-format off */ -static const long REFLOCK__REF = (long) 0x00000001; -static const long REFLOCK__REF_MASK = (long) 0x0fffffff; -static const long REFLOCK__DESTROY = (long) 0x10000000; -static const long REFLOCK__DESTROY_MASK = (long) 0xf0000000; -static const long REFLOCK__POISON = (long) 0x300DEAD0; -/* clang-format on */ +#define REFLOCK__REF ((long) 0x00000001UL) +#define REFLOCK__REF_MASK ((long) 0x0fffffffUL) +#define REFLOCK__DESTROY ((long) 0x10000000UL) +#define REFLOCK__DESTROY_MASK ((long) 0xf0000000UL) +#define REFLOCK__POISON ((long) 0x300dead0UL) static HANDLE reflock__keyed_event = NULL; int reflock_global_init(void) { - NTSTATUS status = - NtCreateKeyedEvent(&reflock__keyed_event, ~(ACCESS_MASK) 0, NULL, 0); + NTSTATUS status = NtCreateKeyedEvent( + &reflock__keyed_event, KEYEDEVENT_ALL_ACCESS, NULL, 0); if (status != STATUS_SUCCESS) return_set_error(-1, RtlNtStatusToDosError(status)); return 0; @@ -1514,22 +1553,20 @@ static void reflock__await_event(void* address) { void reflock_ref(reflock_t* reflock) { long state = InterlockedAdd(&reflock->state, REFLOCK__REF); + + /* Verify that the counter didn't overflow and the lock isn't destroyed. */ + assert((state & REFLOCK__DESTROY_MASK) == 0); unused_var(state); - assert((state & REFLOCK__DESTROY_MASK) == 0); /* Overflow or destroyed. */ } void reflock_unref(reflock_t* reflock) { long state = InterlockedAdd(&reflock->state, -REFLOCK__REF); - long ref_count = state & REFLOCK__REF_MASK; - long destroy = state & REFLOCK__DESTROY_MASK; - unused_var(ref_count); - unused_var(destroy); + /* Verify that the lock was referenced and not already destroyed. */ + assert((state & REFLOCK__DESTROY_MASK & ~REFLOCK__DESTROY) == 0); if (state == REFLOCK__DESTROY) reflock__signal_event(reflock); - else - assert(destroy == 0 || ref_count > 0); } void reflock_unref_and_destroy(reflock_t* reflock) { @@ -1537,8 +1574,8 @@ void reflock_unref_and_destroy(reflock_t* reflock) { InterlockedAdd(&reflock->state, REFLOCK__DESTROY - REFLOCK__REF); long ref_count = state & REFLOCK__REF_MASK; - assert((state & REFLOCK__DESTROY_MASK) == - REFLOCK__DESTROY); /* Underflow or already destroyed. */ + /* Verify that the lock was referenced and not already destroyed. */ + assert((state & REFLOCK__DESTROY_MASK) == REFLOCK__DESTROY); if (ref_count != 0) reflock__await_event(reflock); @@ -1547,9 +1584,9 @@ void reflock_unref_and_destroy(reflock_t* reflock) { assert(state == REFLOCK__DESTROY); } -static const uint32_t SOCK__KNOWN_EPOLL_EVENTS = - EPOLLIN | EPOLLPRI | EPOLLOUT | EPOLLERR | EPOLLHUP | EPOLLRDNORM | - EPOLLRDBAND | EPOLLWRNORM | EPOLLWRBAND | EPOLLMSG | EPOLLRDHUP; +#define SOCK__KNOWN_EPOLL_EVENTS \ + (EPOLLIN | EPOLLPRI | EPOLLOUT | EPOLLERR | EPOLLHUP | EPOLLRDNORM | \ + EPOLLRDBAND | EPOLLWRNORM | EPOLLWRBAND | EPOLLMSG | EPOLLRDHUP) typedef enum sock__poll_status { SOCK__POLL_IDLE = 0, @@ -1558,7 +1595,7 @@ typedef enum sock__poll_status { } sock__poll_status_t; typedef struct sock_state { - OVERLAPPED overlapped; + IO_STATUS_BLOCK io_status_block; AFD_POLL_INFO poll_info; queue_node_t queue_node; tree_node_t tree_node; @@ -1579,20 +1616,16 @@ static inline sock_state_t* sock__alloc(void) { } static inline void sock__free(sock_state_t* sock_state) { + assert(sock_state != NULL); free(sock_state); } -static int sock__cancel_poll(sock_state_t* sock_state) { - HANDLE afd_helper_handle = - poll_group_get_afd_helper_handle(sock_state->poll_group); +static inline int sock__cancel_poll(sock_state_t* sock_state) { assert(sock_state->poll_status == SOCK__POLL_PENDING); - /* CancelIoEx() may fail with ERROR_NOT_FOUND if the overlapped operation has - * already completed. This is not a problem and we proceed normally. */ - if (!HasOverlappedIoCompleted(&sock_state->overlapped) && - !CancelIoEx(afd_helper_handle, &sock_state->overlapped) && - GetLastError() != ERROR_NOT_FOUND) - return_map_error(-1); + if (afd_cancel_poll(poll_group_get_afd_device_handle(sock_state->poll_group), + &sock_state->io_status_block) < 0) + return -1; sock_state->poll_status = SOCK__POLL_CANCELLED; sock_state->pending_events = 0; @@ -1627,7 +1660,7 @@ sock_state_t* sock_new(port_state_t* port_state, SOCKET socket) { tree_node_init(&sock_state->tree_node); queue_node_init(&sock_state->queue_node); - if (port_register_socket_handle(port_state, sock_state, socket) < 0) + if (port_register_socket(port_state, sock_state, socket) < 0) goto err2; return sock_state; @@ -1648,7 +1681,7 @@ static int sock__delete(port_state_t* port_state, sock__cancel_poll(sock_state); port_cancel_socket_update(port_state, sock_state); - port_unregister_socket_handle(port_state, sock_state); + port_unregister_socket(port_state, sock_state); sock_state->delete_pending = true; } @@ -1682,7 +1715,7 @@ int sock_set_event(port_state_t* port_state, const struct epoll_event* ev) { /* EPOLLERR and EPOLLHUP are always reported, even when not requested by the * caller. However they are disabled after a event has been reported for a - * socket for which the EPOLLONESHOT flag as set. */ + * socket for which the EPOLLONESHOT flag was set. */ uint32_t events = ev->events | EPOLLERR | EPOLLHUP; sock_state->user_events = events; @@ -1769,11 +1802,9 @@ int sock_update(port_state_t* port_state, sock_state_t* sock_state) { sock_state->poll_info.Handles[0].Events = sock__epoll_events_to_afd_events(sock_state->user_events); - memset(&sock_state->overlapped, 0, sizeof sock_state->overlapped); - - if (afd_poll(poll_group_get_afd_helper_handle(sock_state->poll_group), + if (afd_poll(poll_group_get_afd_device_handle(sock_state->poll_group), &sock_state->poll_info, - &sock_state->overlapped) < 0) { + &sock_state->io_status_block) < 0) { switch (GetLastError()) { case ERROR_IO_PENDING: /* Overlapped poll operation in progress; this is expected. */ @@ -1801,10 +1832,10 @@ int sock_update(port_state_t* port_state, sock_state_t* sock_state) { } int sock_feed_event(port_state_t* port_state, - OVERLAPPED* overlapped, + IO_STATUS_BLOCK* io_status_block, struct epoll_event* ev) { sock_state_t* sock_state = - container_of(overlapped, sock_state_t, overlapped); + container_of(io_status_block, sock_state_t, io_status_block); AFD_POLL_INFO* poll_info = &sock_state->poll_info; uint32_t epoll_events = 0; @@ -1815,10 +1846,10 @@ int sock_feed_event(port_state_t* port_state, /* Socket has been deleted earlier and can now be freed. */ return sock__delete(port_state, sock_state, false); - } else if ((NTSTATUS) overlapped->Internal == STATUS_CANCELLED) { + } else if (io_status_block->Status == STATUS_CANCELLED) { /* The poll request was cancelled by CancelIoEx. */ - } else if (!NT_SUCCESS(overlapped->Internal)) { + } else if (!NT_SUCCESS(io_status_block->Status)) { /* The overlapped request itself failed in an unexpected way. */ epoll_events = EPOLLERR; @@ -1855,6 +1886,10 @@ int sock_feed_event(port_state_t* port_state, return 1; } +sock_state_t* sock_state_from_queue_node(queue_node_t* queue_node) { + return container_of(queue_node, sock_state_t, queue_node); +} + queue_node_t* sock_state_to_queue_node(sock_state_t* sock_state) { return &sock_state->queue_node; } @@ -1867,10 +1902,6 @@ tree_node_t* sock_state_to_tree_node(sock_state_t* sock_state) { return &sock_state->tree_node; } -sock_state_t* sock_state_from_queue_node(queue_node_t* queue_node) { - return container_of(queue_node, sock_state_t, queue_node); -} - void ts_tree_init(ts_tree_t* ts_tree) { tree_init(&ts_tree->tree); InitializeSRWLock(&ts_tree->lock); @@ -1983,23 +2014,23 @@ static inline void tree__rotate_right(tree_t* tree, tree_node_t* node) { break; \ } -#define TREE__FIXUP_AFTER_INSERT(cis, trans) \ - tree_node_t* grandparent = parent->parent; \ - tree_node_t* uncle = grandparent->trans; \ - \ - if (uncle && uncle->red) { \ - parent->red = uncle->red = false; \ - grandparent->red = true; \ - node = grandparent; \ - } else { \ - if (node == parent->trans) { \ - tree__rotate_##cis(tree, parent); \ - node = parent; \ - parent = node->parent; \ - } \ - parent->red = false; \ - grandparent->red = true; \ - tree__rotate_##trans(tree, grandparent); \ +#define TREE__REBALANCE_AFTER_INSERT(cis, trans) \ + tree_node_t* grandparent = parent->parent; \ + tree_node_t* uncle = grandparent->trans; \ + \ + if (uncle && uncle->red) { \ + parent->red = uncle->red = false; \ + grandparent->red = true; \ + node = grandparent; \ + } else { \ + if (node == parent->trans) { \ + tree__rotate_##cis(tree, parent); \ + node = parent; \ + parent = node->parent; \ + } \ + parent->red = false; \ + grandparent->red = true; \ + tree__rotate_##trans(tree, grandparent); \ } int tree_add(tree_t* tree, tree_node_t* node, uintptr_t key) { @@ -2027,9 +2058,9 @@ int tree_add(tree_t* tree, tree_node_t* node, uintptr_t key) { for (; parent && parent->red; parent = node->parent) { if (parent == parent->parent->left) { - TREE__FIXUP_AFTER_INSERT(left, right) + TREE__REBALANCE_AFTER_INSERT(left, right) } else { - TREE__FIXUP_AFTER_INSERT(right, left) + TREE__REBALANCE_AFTER_INSERT(right, left) } } tree->root->red = false; @@ -2037,7 +2068,7 @@ int tree_add(tree_t* tree, tree_node_t* node, uintptr_t key) { return 0; } -#define TREE__FIXUP_AFTER_REMOVE(cis, trans) \ +#define TREE__REBALANCE_AFTER_REMOVE(cis, trans) \ tree_node_t* sibling = parent->trans; \ \ if (sibling->red) { \ @@ -2123,9 +2154,9 @@ void tree_del(tree_t* tree, tree_node_t* node) { if (node == tree->root) break; if (node == parent->left) { - TREE__FIXUP_AFTER_REMOVE(left, right) + TREE__REBALANCE_AFTER_REMOVE(left, right) } else { - TREE__FIXUP_AFTER_REMOVE(right, left) + TREE__REBALANCE_AFTER_REMOVE(right, left) } node = parent; parent = parent->parent; @@ -2152,6 +2183,10 @@ tree_node_t* tree_root(const tree_t* tree) { return tree->root; } +#ifndef SIO_BSP_HANDLE_POLL +#define SIO_BSP_HANDLE_POLL 0x4800001D +#endif + #ifndef SIO_BASE_HANDLE #define SIO_BASE_HANDLE 0x48000022 #endif @@ -2167,20 +2202,52 @@ int ws_global_init(void) { return 0; } -SOCKET ws_get_base_socket(SOCKET socket) { - SOCKET base_socket; +static inline SOCKET ws__ioctl_get_bsp_socket(SOCKET socket, DWORD ioctl) { + SOCKET bsp_socket; DWORD bytes; if (WSAIoctl(socket, - SIO_BASE_HANDLE, + ioctl, NULL, 0, - &base_socket, - sizeof base_socket, + &bsp_socket, + sizeof bsp_socket, &bytes, NULL, - NULL) == SOCKET_ERROR) - return_map_error(INVALID_SOCKET); + NULL) != SOCKET_ERROR) + return bsp_socket; + else + return INVALID_SOCKET; +} + +SOCKET ws_get_base_socket(SOCKET socket) { + SOCKET base_socket; + DWORD error; - return base_socket; + for (;;) { + base_socket = ws__ioctl_get_bsp_socket(socket, SIO_BASE_HANDLE); + if (base_socket != INVALID_SOCKET) + return base_socket; + + error = GetLastError(); + if (error == WSAENOTSOCK) + return_set_error(INVALID_SOCKET, error); + + /* Even though Microsoft documentation clearly states that LSPs should + * never intercept the `SIO_BASE_HANDLE` ioctl [1], Komodia based LSPs do + * so anyway, breaking it, with the apparent intention of preventing LSP + * bypass [2]. Fortunately they don't handle `SIO_BSP_HANDLE_POLL`, which + * will at least let us obtain the socket associated with the next winsock + * protocol chain entry. If this succeeds, loop around and call + * `SIO_BASE_HANDLE` again with the returned BSP socket, to make sure that + * we unwrap all layers and retrieve the actual base socket. + * [1] https://docs.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls + * [2] https://www.komodia.com/newwiki/index.php?title=Komodia%27s_Redirector_bug_fixes#Version_2.2.2.6 + */ + base_socket = ws__ioctl_get_bsp_socket(socket, SIO_BSP_HANDLE_POLL); + if (base_socket != INVALID_SOCKET && base_socket != socket) + socket = base_socket; + else + return_set_error(INVALID_SOCKET, error); + } } diff --git a/deps/zmq/external/wepoll/wepoll.h b/deps/zmq/external/wepoll/wepoll.h index 7b522984669..daf6bdb0016 100644 --- a/deps/zmq/external/wepoll/wepoll.h +++ b/deps/zmq/external/wepoll/wepoll.h @@ -2,7 +2,7 @@ * wepoll - epoll for Windows * https://github.com/piscisaureus/wepoll * - * Copyright 2012-2018, Bert Belder + * Copyright 2012-2020, Bert Belder * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,8 +38,6 @@ #include -/* clang-format off */ - enum EPOLL_EVENTS { EPOLLIN = (int) (1U << 0), EPOLLPRI = (int) (1U << 1), @@ -72,8 +70,6 @@ enum EPOLL_EVENTS { #define EPOLL_CTL_MOD 2 #define EPOLL_CTL_DEL 3 -/* clang-format on */ - typedef void* HANDLE; typedef uintptr_t SOCKET; diff --git a/deps/zmq/include/zmq.h b/deps/zmq/include/zmq.h index d05659f75c5..6520b073a0a 100644 --- a/deps/zmq/include/zmq.h +++ b/deps/zmq/include/zmq.h @@ -1,32 +1,5 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . - - ************************************************************************* +/* SPDX-License-Identifier: MPL-2.0 */ +/* ************************************************************************* NOTE to contributors. This file comprises the principal public contract for ZeroMQ API users. Any change to this file supplied in a stable release SHOULD not break existing applications. @@ -41,7 +14,7 @@ /* Version macros for compile-time API version detection */ #define ZMQ_VERSION_MAJOR 4 #define ZMQ_VERSION_MINOR 3 -#define ZMQ_VERSION_PATCH 4 +#define ZMQ_VERSION_PATCH 5 #define ZMQ_MAKE_VERSION(major, minor, patch) \ ((major) *10000 + (minor) *100 + (patch)) @@ -57,23 +30,11 @@ extern "C" { #endif #include #include -#if defined _WIN32 -// Set target version to Windows Server 2008, Windows Vista or higher. -// Windows XP (0x0501) is supported but without client & server socket types. -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 -#endif - -#ifdef __MINGW32__ -// Require Windows XP or higher with MinGW for getaddrinfo(). -#if (_WIN32_WINNT >= 0x0501) -#else -#error You need at least Windows XP target -#endif -#endif -#endif /* Handle DSO symbol visibility */ +#if defined ZMQ_NO_EXPORT +#define ZMQ_EXPORT +#else #if defined _WIN32 #if defined ZMQ_STATIC #define ZMQ_EXPORT @@ -91,6 +52,7 @@ extern "C" { #define ZMQ_EXPORT #endif #endif +#endif /* Define integer types needed for event interface */ #define ZMQ_DEFINED_STDINT 1 @@ -116,6 +78,11 @@ typedef unsigned __int8 uint8_t; #include #endif +#if !defined _WIN32 +// needed for sigset_t definition in zmq_ppoll +#include +#endif + // 32-bit AIX's pollfd struct members are called reqevents and rtnevents so it // defines compatibility macros for them. Need to include that header first to // stop build failures since zmq_pollset_t defines them as events and revents. @@ -264,7 +231,7 @@ typedef struct zmq_msg_t #endif } zmq_msg_t; -typedef void(zmq_free_fn) (void *data_, void *hint_); +typedef void (zmq_free_fn) (void *data_, void *hint_); ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg_); ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg_, size_t size_); @@ -572,7 +539,7 @@ zmq_z85_encode (char *dest_, const uint8_t *data_, size_t size_); /* Decode data with Z85 encoding. Returns decoded data */ ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest_, const char *string_); -/* Generate z85-encoded public and private keypair with tweetnacl/libsodium. */ +/* Generate z85-encoded public and private keypair with libsodium. */ /* Returns 0 on success. */ ZMQ_EXPORT int zmq_curve_keypair (char *z85_public_key_, char *z85_secret_key_); @@ -598,7 +565,7 @@ ZMQ_EXPORT void zmq_atomic_counter_destroy (void **counter_p_); #define ZMQ_HAVE_TIMERS -typedef void(zmq_timer_fn) (int timer_id, void *arg); +typedef void (zmq_timer_fn) (int timer_id, void *arg); ZMQ_EXPORT void *zmq_timers_new (void); ZMQ_EXPORT int zmq_timers_destroy (void **timers_p); @@ -635,7 +602,7 @@ ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_); /* Sleeps for specified number of seconds. */ ZMQ_EXPORT void zmq_sleep (int seconds_); -typedef void(zmq_thread_fn) (void *); +typedef void (zmq_thread_fn) (void *); /* Start a thread. Returns a handle to the thread. */ ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn *func_, void *arg_); @@ -683,11 +650,30 @@ ZMQ_EXPORT void zmq_threadclose (void *thread_); #define ZMQ_HELLO_MSG 110 #define ZMQ_DISCONNECT_MSG 111 #define ZMQ_PRIORITY 112 +#define ZMQ_BUSY_POLL 113 +#define ZMQ_HICCUP_MSG 114 +#define ZMQ_XSUB_VERBOSE_UNSUBSCRIBE 115 +#define ZMQ_TOPICS_COUNT 116 +#define ZMQ_NORM_MODE 117 +#define ZMQ_NORM_UNICAST_NACK 118 +#define ZMQ_NORM_BUFFER_SIZE 119 +#define ZMQ_NORM_SEGMENT_SIZE 120 +#define ZMQ_NORM_BLOCK_SIZE 121 +#define ZMQ_NORM_NUM_PARITY 122 +#define ZMQ_NORM_NUM_AUTOPARITY 123 +#define ZMQ_NORM_PUSH 124 + +/* DRAFT ZMQ_NORM_MODE options */ +#define ZMQ_NORM_FIXED 0 +#define ZMQ_NORM_CC 1 +#define ZMQ_NORM_CCL 2 +#define ZMQ_NORM_CCE 3 +#define ZMQ_NORM_CCE_ECNONLY 4 /* DRAFT ZMQ_RECONNECT_STOP options */ #define ZMQ_RECONNECT_STOP_CONN_REFUSED 0x1 #define ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED 0x2 -#define ZMQ_RECONNECT_STOP_AFTER_DISCONNECT 0x3 +#define ZMQ_RECONNECT_STOP_AFTER_DISCONNECT 0x4 /* DRAFT Context options */ #define ZMQ_ZERO_COPY_RECV 10 @@ -776,6 +762,19 @@ ZMQ_EXPORT int zmq_socket_monitor_versioned ( void *s_, const char *addr_, uint64_t events_, int event_version_, int type_); ZMQ_EXPORT int zmq_socket_monitor_pipes_stats (void *s); +#if !defined _WIN32 +ZMQ_EXPORT int zmq_ppoll (zmq_pollitem_t *items_, + int nitems_, + long timeout_, + const sigset_t *sigmask_); +#else +// Windows has no sigset_t +ZMQ_EXPORT int zmq_ppoll (zmq_pollitem_t *items_, + int nitems_, + long timeout_, + const void *sigmask_); +#endif + #endif // ZMQ_BUILD_DRAFT_API diff --git a/deps/zmq/include/zmq_utils.h b/deps/zmq/include/zmq_utils.h index b9398d57e1e..c4094063217 100644 --- a/deps/zmq/include/zmq_utils.h +++ b/deps/zmq/include/zmq_utils.h @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ /* This file is deprecated, and all its functionality provided by zmq.h */ /* Note that -Wpedantic compilation requires GCC to avoid using its custom diff --git a/deps/zmq/src/address.cpp b/deps/zmq/src/address.cpp index 9ec83c2fdf3..f69a75dbe7b 100644 --- a/deps/zmq/src/address.cpp +++ b/deps/zmq/src/address.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -48,9 +21,7 @@ zmq::address_t::address_t (const std::string &protocol_, const std::string &address_, ctx_t *parent_) : - protocol (protocol_), - address (address_), - parent (parent_) + protocol (protocol_), address (address_), parent (parent_) { resolved.dummy = NULL; } diff --git a/deps/zmq/src/address.hpp b/deps/zmq/src/address.hpp index 3c0a51de4d1..0082646200a 100644 --- a/deps/zmq/src/address.hpp +++ b/deps/zmq/src/address.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_ADDRESS_HPP_INCLUDED__ #define __ZMQ_ADDRESS_HPP_INCLUDED__ diff --git a/deps/zmq/src/array.hpp b/deps/zmq/src/array.hpp index 8c813824413..0abfd3fb17d 100644 --- a/deps/zmq/src/array.hpp +++ b/deps/zmq/src/array.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_ARRAY_INCLUDED__ #define __ZMQ_ARRAY_INCLUDED__ diff --git a/deps/zmq/src/atomic_counter.hpp b/deps/zmq/src/atomic_counter.hpp index d05837a135a..83ca9769e71 100644 --- a/deps/zmq/src/atomic_counter.hpp +++ b/deps/zmq/src/atomic_counter.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_ATOMIC_COUNTER_HPP_INCLUDED__ #define __ZMQ_ATOMIC_COUNTER_HPP_INCLUDED__ @@ -197,7 +170,10 @@ class atomic_counter_t #endif } - integer_t get () const ZMQ_NOEXCEPT { return _value; } + integer_t get () const ZMQ_NOEXCEPT + { + return _value; + } private: #if defined ZMQ_ATOMIC_COUNTER_CXX11 diff --git a/deps/zmq/src/atomic_ptr.hpp b/deps/zmq/src/atomic_ptr.hpp index fa8bc7c3512..841a7d83c75 100644 --- a/deps/zmq/src/atomic_ptr.hpp +++ b/deps/zmq/src/atomic_ptr.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_ATOMIC_PTR_HPP_INCLUDED__ #define __ZMQ_ATOMIC_PTR_HPP_INCLUDED__ diff --git a/deps/zmq/src/blob.hpp b/deps/zmq/src/blob.hpp index 542216188ca..1b758e97b72 100644 --- a/deps/zmq/src/blob.hpp +++ b/deps/zmq/src/blob.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_BLOB_HPP_INCLUDED__ #define __ZMQ_BLOB_HPP_INCLUDED__ @@ -81,7 +54,7 @@ struct blob_t _size (size_), _owned (true) { - alloc_assert (_data); + alloc_assert (!_size || _data); } // Creates a blob_t of a given size, an initializes content by copying @@ -91,8 +64,10 @@ struct blob_t _size (size_), _owned (true) { - alloc_assert (_data); - memcpy (_data, data_, size_); + alloc_assert (!size_ || _data); + if (size_ && _data) { + memcpy (_data, data_, size_); + } } // Creates a blob_t for temporary use that only references a @@ -100,9 +75,7 @@ struct blob_t // Use with caution and ensure that the blob_t will not outlive // the referenced data. blob_t (unsigned char *const data_, const size_t size_, reference_tag_t) : - _data (data_), - _size (size_), - _owned (false) + _data (data_), _size (size_), _owned (false) { } @@ -116,7 +89,7 @@ struct blob_t unsigned char *data () { return _data; } // Defines an order relationship on blob_t. - bool operator< (blob_t const &other_) const + bool operator<(blob_t const &other_) const { const int cmpres = memcmp (_data, other_._data, std::min (_size, other_._size)); @@ -128,10 +101,12 @@ struct blob_t { clear (); _data = static_cast (malloc (other_._size)); - alloc_assert (_data); + alloc_assert (!other_._size || _data); _size = other_._size; _owned = true; - memcpy (_data, other_._data, _size); + if (_size && _data) { + memcpy (_data, other_._data, _size); + } } // Sets a blob_t to a copy of a given buffer. @@ -139,10 +114,12 @@ struct blob_t { clear (); _data = static_cast (malloc (size_)); - alloc_assert (_data); + alloc_assert (!size_ || _data); _size = size_; _owned = true; - memcpy (_data, data_, size_); + if (size_ && _data) { + memcpy (_data, data_, size_); + } } // Empties a blob_t. @@ -184,7 +161,10 @@ struct blob_t return *this; } #else - blob_t (const blob_t &other) : _owned (false) { set_deep_copy (other); } + blob_t (const blob_t &other) : _owned (false) + { + set_deep_copy (other); + } blob_t &operator= (const blob_t &other) { if (this != &other) { diff --git a/deps/zmq/src/channel.cpp b/deps/zmq/src/channel.cpp index 6a396228d5b..f1ea118e068 100644 --- a/deps/zmq/src/channel.cpp +++ b/deps/zmq/src/channel.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2020 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -35,8 +8,7 @@ #include "msg.hpp" zmq::channel_t::channel_t (class ctx_t *parent_, uint32_t tid_, int sid_) : - socket_base_t (parent_, tid_, sid_, true), - _pipe (NULL) + socket_base_t (parent_, tid_, sid_, true), _pipe (NULL) { options.type = ZMQ_CHANNEL; } diff --git a/deps/zmq/src/channel.hpp b/deps/zmq/src/channel.hpp index 0eb360a00f2..6aee0117f63 100644 --- a/deps/zmq/src/channel.hpp +++ b/deps/zmq/src/channel.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2020 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_CHANNEL_HPP_INCLUDED__ #define __ZMQ_CHANNEL_HPP_INCLUDED__ diff --git a/deps/zmq/src/client.cpp b/deps/zmq/src/client.cpp index f26b1386093..61f1a20f1ee 100644 --- a/deps/zmq/src/client.cpp +++ b/deps/zmq/src/client.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -38,6 +11,7 @@ zmq::client_t::client_t (class ctx_t *parent_, uint32_t tid_, int sid_) : { options.type = ZMQ_CLIENT; options.can_send_hello_msg = true; + options.can_recv_hiccup_msg = true; } zmq::client_t::~client_t () diff --git a/deps/zmq/src/client.hpp b/deps/zmq/src/client.hpp index c166f0e852f..5029de65b93 100644 --- a/deps/zmq/src/client.hpp +++ b/deps/zmq/src/client.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_CLIENT_HPP_INCLUDED__ #define __ZMQ_CLIENT_HPP_INCLUDED__ diff --git a/deps/zmq/src/clock.cpp b/deps/zmq/src/clock.cpp index 79522ad382d..fc2151f63b3 100644 --- a/deps/zmq/src/clock.cpp +++ b/deps/zmq/src/clock.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "clock.hpp" @@ -126,9 +99,11 @@ static f_compatible_get_tick_count64 my_get_tick_count64 = init_compatible_get_tick_count64 (); #endif +#ifndef ZMQ_HAVE_WINDOWS const uint64_t usecs_per_msec = 1000; -const uint64_t usecs_per_sec = 1000000; const uint64_t nsecs_per_usec = 1000; +#endif +const uint64_t usecs_per_sec = 1000000; zmq::clock_t::clock_t () : _last_tsc (rdtsc ()), @@ -193,6 +168,7 @@ uint64_t zmq::clock_t::now_us () #else + LIBZMQ_UNUSED (nsecs_per_usec); // Use POSIX gettimeofday function to get precise time. struct timeval tv; int rc = gettimeofday (&tv, NULL); @@ -241,11 +217,12 @@ uint64_t zmq::clock_t::rdtsc () #elif defined(_MSC_VER) && defined(_M_ARM) // NC => added for windows ARM return __rdpmccntr64 (); #elif defined(_MSC_VER) && defined(_M_ARM64) // NC => added for windows ARM64 - //return __rdpmccntr64 (); - //return __rdtscp (nullptr); - // todo: find proper implementation for ARM64 - static uint64_t snCounter = 0; - return ++snCounter; + const int64_t pmccntr_el0 = (((3 & 1) << 14) | // op0 + ((3 & 7) << 11) | // op1 + ((9 & 15) << 7) | // crn + ((13 & 15) << 3) | // crm + ((0 & 7) << 0)); // op2 + return _ReadStatusReg (pmccntr_el0); #elif (defined __GNUC__ && (defined __i386__ || defined __x86_64__)) uint32_t low, high; __asm__ volatile("rdtsc" : "=a"(low), "=d"(high)); diff --git a/deps/zmq/src/clock.hpp b/deps/zmq/src/clock.hpp index 300d1801a7b..96302c2b973 100644 --- a/deps/zmq/src/clock.hpp +++ b/deps/zmq/src/clock.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_CLOCK_HPP_INCLUDED__ #define __ZMQ_CLOCK_HPP_INCLUDED__ diff --git a/deps/zmq/src/command.hpp b/deps/zmq/src/command.hpp index c92f7a7c631..135d1aee891 100644 --- a/deps/zmq/src/command.hpp +++ b/deps/zmq/src/command.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_COMMAND_HPP_INCLUDED__ #define __ZMQ_COMMAND_HPP_INCLUDED__ @@ -33,6 +6,7 @@ #include #include "stdint.hpp" #include "endpoint.hpp" +#include "platform.hpp" namespace zmq { @@ -44,12 +18,7 @@ class socket_base_t; // This structure defines the commands that can be sent between threads. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4324) // C4324: alignment padding warnings -__declspec(align (64)) -#endif - struct command_t +struct command_t { // Object to process the command. zmq::object_t *destination; @@ -216,9 +185,12 @@ __declspec(align (64)) } args; #ifdef _MSC_VER }; -#pragma warning(pop) #else -} __attribute__ ((aligned (64))); +} +#ifdef HAVE_POSIX_MEMALIGN +__attribute__ ((aligned (ZMQ_CACHELINE_SIZE))) +#endif +; #endif } diff --git a/deps/zmq/src/compat.hpp b/deps/zmq/src/compat.hpp index 47744b98e2a..f909377410f 100644 --- a/deps/zmq/src/compat.hpp +++ b/deps/zmq/src/compat.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2020 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_COMPAT_HPP_INCLUDED__ #define __ZMQ_COMPAT_HPP_INCLUDED__ diff --git a/deps/zmq/src/condition_variable.hpp b/deps/zmq/src/condition_variable.hpp index 47d14e79532..815821c9b29 100644 --- a/deps/zmq/src/condition_variable.hpp +++ b/deps/zmq/src/condition_variable.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_CONDITON_VARIABLE_HPP_INCLUDED__ #define __ZMQ_CONDITON_VARIABLE_HPP_INCLUDED__ diff --git a/deps/zmq/src/config.hpp b/deps/zmq/src/config.hpp index c355c6d7dc6..2feb0d4e726 100644 --- a/deps/zmq/src/config.hpp +++ b/deps/zmq/src/config.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_CONFIG_HPP_INCLUDED__ #define __ZMQ_CONFIG_HPP_INCLUDED__ diff --git a/deps/zmq/src/ctx.cpp b/deps/zmq/src/ctx.cpp index 2b64c5104e6..1515051fa6f 100644 --- a/deps/zmq/src/ctx.cpp +++ b/deps/zmq/src/ctx.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2017 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -328,6 +301,7 @@ int zmq::ctx_t::get (int option_, void *optval_, const size_t *optvallen_) switch (option_) { case ZMQ_MAX_SOCKETS: if (is_int) { + scoped_lock_t locker (_opt_sync); *value = _max_sockets; return 0; } @@ -342,6 +316,7 @@ int zmq::ctx_t::get (int option_, void *optval_, const size_t *optvallen_) case ZMQ_IO_THREADS: if (is_int) { + scoped_lock_t locker (_opt_sync); *value = _io_thread_count; return 0; } @@ -349,6 +324,7 @@ int zmq::ctx_t::get (int option_, void *optval_, const size_t *optvallen_) case ZMQ_IPV6: if (is_int) { + scoped_lock_t locker (_opt_sync); *value = _ipv6; return 0; } @@ -356,6 +332,7 @@ int zmq::ctx_t::get (int option_, void *optval_, const size_t *optvallen_) case ZMQ_BLOCKY: if (is_int) { + scoped_lock_t locker (_opt_sync); *value = _blocky; return 0; } @@ -363,6 +340,7 @@ int zmq::ctx_t::get (int option_, void *optval_, const size_t *optvallen_) case ZMQ_MAX_MSGSZ: if (is_int) { + scoped_lock_t locker (_opt_sync); *value = _max_msgsz; return 0; } @@ -370,6 +348,7 @@ int zmq::ctx_t::get (int option_, void *optval_, const size_t *optvallen_) case ZMQ_MSG_T_SIZE: if (is_int) { + scoped_lock_t locker (_opt_sync); *value = sizeof (zmq_msg_t); return 0; } @@ -377,6 +356,7 @@ int zmq::ctx_t::get (int option_, void *optval_, const size_t *optvallen_) case ZMQ_ZERO_COPY_RECV: if (is_int) { + scoped_lock_t locker (_opt_sync); *value = _zero_copy; return 0; } diff --git a/deps/zmq/src/ctx.hpp b/deps/zmq/src/ctx.hpp index 0ccd68fa5b0..2000f990514 100644 --- a/deps/zmq/src/ctx.hpp +++ b/deps/zmq/src/ctx.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2017 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_CTX_HPP_INCLUDED__ #define __ZMQ_CTX_HPP_INCLUDED__ diff --git a/deps/zmq/src/curve_client.cpp b/deps/zmq/src/curve_client.cpp index 5d1f64e8281..f56ff54aa62 100644 --- a/deps/zmq/src/curve_client.cpp +++ b/deps/zmq/src/curve_client.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" diff --git a/deps/zmq/src/curve_client.hpp b/deps/zmq/src/curve_client.hpp index 9d51d3a05f0..d3705b8c9a1 100644 --- a/deps/zmq/src/curve_client.hpp +++ b/deps/zmq/src/curve_client.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_CURVE_CLIENT_HPP_INCLUDED__ #define __ZMQ_CURVE_CLIENT_HPP_INCLUDED__ diff --git a/deps/zmq/src/curve_client_tools.hpp b/deps/zmq/src/curve_client_tools.hpp index 3c098ba937e..d49cb4ba61a 100644 --- a/deps/zmq/src/curve_client_tools.hpp +++ b/deps/zmq/src/curve_client_tools.hpp @@ -1,40 +1,11 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_CURVE_CLIENT_TOOLS_HPP_INCLUDED__ #define __ZMQ_CURVE_CLIENT_TOOLS_HPP_INCLUDED__ #ifdef ZMQ_HAVE_CURVE -#if defined(ZMQ_USE_TWEETNACL) -#include "tweetnacl.h" -#elif defined(ZMQ_USE_LIBSODIUM) +#if defined(ZMQ_USE_LIBSODIUM) #include "sodium.h" #endif @@ -180,6 +151,12 @@ struct curve_client_tools_t // Create Box [C + vouch + metadata](C'->S') std::fill (initiate_plaintext.begin (), initiate_plaintext.begin () + crypto_box_ZEROBYTES, 0); + + // False positives due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578 +#if __GNUC__ >= 11 +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overflow=" +#endif memcpy (&initiate_plaintext[crypto_box_ZEROBYTES], public_key_, 32); memcpy (&initiate_plaintext[crypto_box_ZEROBYTES + 32], vouch_nonce + 8, 16); @@ -189,6 +166,10 @@ struct curve_client_tools_t memcpy (&initiate_plaintext[crypto_box_ZEROBYTES + 48 + 80], metadata_plaintext_, metadata_length_); } +#if __GNUC__ >= 11 +#pragma GCC diagnostic pop +#pragma GCC diagnostic pop +#endif memcpy (initiate_nonce, "CurveZMQINITIATE", 16); put_uint64 (initiate_nonce + 16, cn_nonce_); diff --git a/deps/zmq/src/curve_mechanism_base.cpp b/deps/zmq/src/curve_mechanism_base.cpp index 6f0173e1d42..f0104553c00 100644 --- a/deps/zmq/src/curve_mechanism_base.cpp +++ b/deps/zmq/src/curve_mechanism_base.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" diff --git a/deps/zmq/src/curve_mechanism_base.hpp b/deps/zmq/src/curve_mechanism_base.hpp index a72965e9b2b..fe75df8819d 100644 --- a/deps/zmq/src/curve_mechanism_base.hpp +++ b/deps/zmq/src/curve_mechanism_base.hpp @@ -1,40 +1,11 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_CURVE_MECHANISM_BASE_HPP_INCLUDED__ #define __ZMQ_CURVE_MECHANISM_BASE_HPP_INCLUDED__ #ifdef ZMQ_HAVE_CURVE -#if defined(ZMQ_USE_TWEETNACL) -#include "tweetnacl.h" -#elif defined(ZMQ_USE_LIBSODIUM) +#if defined(ZMQ_USE_LIBSODIUM) #include "sodium.h" #endif diff --git a/deps/zmq/src/curve_server.cpp b/deps/zmq/src/curve_server.cpp index fadfc746306..d35e57b6de5 100644 --- a/deps/zmq/src/curve_server.cpp +++ b/deps/zmq/src/curve_server.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" diff --git a/deps/zmq/src/curve_server.hpp b/deps/zmq/src/curve_server.hpp index 995efce0315..c836032d91e 100644 --- a/deps/zmq/src/curve_server.hpp +++ b/deps/zmq/src/curve_server.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_CURVE_SERVER_HPP_INCLUDED__ #define __ZMQ_CURVE_SERVER_HPP_INCLUDED__ diff --git a/deps/zmq/src/dbuffer.hpp b/deps/zmq/src/dbuffer.hpp index 00ea66befcb..cb9ae3952a9 100644 --- a/deps/zmq/src/dbuffer.hpp +++ b/deps/zmq/src/dbuffer.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_DBUFFER_HPP_INCLUDED__ #define __ZMQ_DBUFFER_HPP_INCLUDED__ diff --git a/deps/zmq/src/dealer.cpp b/deps/zmq/src/dealer.cpp index bf1c41da85a..982bc4a6e67 100644 --- a/deps/zmq/src/dealer.cpp +++ b/deps/zmq/src/dealer.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -34,11 +7,11 @@ #include "msg.hpp" zmq::dealer_t::dealer_t (class ctx_t *parent_, uint32_t tid_, int sid_) : - socket_base_t (parent_, tid_, sid_), - _probe_router (false) + socket_base_t (parent_, tid_, sid_), _probe_router (false) { options.type = ZMQ_DEALER; options.can_send_hello_msg = true; + options.can_recv_hiccup_msg = true; } zmq::dealer_t::~dealer_t () diff --git a/deps/zmq/src/dealer.hpp b/deps/zmq/src/dealer.hpp index 5515fd39ced..11f17838949 100644 --- a/deps/zmq/src/dealer.hpp +++ b/deps/zmq/src/dealer.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_DEALER_HPP_INCLUDED__ #define __ZMQ_DEALER_HPP_INCLUDED__ diff --git a/deps/zmq/src/decoder.hpp b/deps/zmq/src/decoder.hpp index a2cd5a99d2c..d51eada22a4 100644 --- a/deps/zmq/src/decoder.hpp +++ b/deps/zmq/src/decoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_DECODER_HPP_INCLUDED__ #define __ZMQ_DECODER_HPP_INCLUDED__ @@ -58,10 +31,7 @@ class decoder_base_t : public i_decoder { public: explicit decoder_base_t (const size_t buf_size_) : - _next (NULL), - _read_pos (NULL), - _to_read (0), - _allocator (buf_size_) + _next (NULL), _read_pos (NULL), _to_read (0), _allocator (buf_size_) { _buf = _allocator.allocate (); } diff --git a/deps/zmq/src/decoder_allocators.cpp b/deps/zmq/src/decoder_allocators.cpp index 078d294a822..8eedea33660 100644 --- a/deps/zmq/src/decoder_allocators.cpp +++ b/deps/zmq/src/decoder_allocators.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "decoder_allocators.hpp" @@ -102,6 +75,7 @@ void zmq::shared_message_memory_allocator::deallocate () { zmq::atomic_counter_t *c = reinterpret_cast (_buf); if (_buf && !c->sub (1)) { + c->~atomic_counter_t (); std::free (_buf); } clear (); diff --git a/deps/zmq/src/decoder_allocators.hpp b/deps/zmq/src/decoder_allocators.hpp index 2620f1b8ecc..e28cbc96276 100644 --- a/deps/zmq/src/decoder_allocators.hpp +++ b/deps/zmq/src/decoder_allocators.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_DECODER_ALLOCATORS_HPP_INCLUDED__ #define __ZMQ_DECODER_ALLOCATORS_HPP_INCLUDED__ diff --git a/deps/zmq/src/devpoll.cpp b/deps/zmq/src/devpoll.cpp index 11b38ccb77d..6b808db1c2a 100644 --- a/deps/zmq/src/devpoll.cpp +++ b/deps/zmq/src/devpoll.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "devpoll.hpp" diff --git a/deps/zmq/src/devpoll.hpp b/deps/zmq/src/devpoll.hpp index e57814b9cbc..43c1f858ae7 100644 --- a/deps/zmq/src/devpoll.hpp +++ b/deps/zmq/src/devpoll.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_DEVPOLL_HPP_INCLUDED__ #define __ZMQ_DEVPOLL_HPP_INCLUDED__ diff --git a/deps/zmq/src/dgram.cpp b/deps/zmq/src/dgram.cpp index 879ff4da707..2156eb0e554 100644 --- a/deps/zmq/src/dgram.cpp +++ b/deps/zmq/src/dgram.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -37,10 +10,7 @@ #include "err.hpp" zmq::dgram_t::dgram_t (class ctx_t *parent_, uint32_t tid_, int sid_) : - socket_base_t (parent_, tid_, sid_), - _pipe (NULL), - _last_in (NULL), - _more_out (false) + socket_base_t (parent_, tid_, sid_), _pipe (NULL), _more_out (false) { options.type = ZMQ_DGRAM; options.raw_socket = true; @@ -71,9 +41,6 @@ void zmq::dgram_t::xattach_pipe (pipe_t *pipe_, void zmq::dgram_t::xpipe_terminated (pipe_t *pipe_) { if (pipe_ == _pipe) { - if (_last_in == _pipe) { - _last_in = NULL; - } _pipe = NULL; } } @@ -147,7 +114,6 @@ int zmq::dgram_t::xrecv (msg_t *msg_) errno = EAGAIN; return -1; } - _last_in = _pipe; return 0; } diff --git a/deps/zmq/src/dgram.hpp b/deps/zmq/src/dgram.hpp index 51385aad6ba..ea06a9d7659 100644 --- a/deps/zmq/src/dgram.hpp +++ b/deps/zmq/src/dgram.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_DGRAM_HPP_INCLUDED__ #define __ZMQ_DGRAM_HPP_INCLUDED__ @@ -62,8 +35,6 @@ class dgram_t ZMQ_FINAL : public socket_base_t private: zmq::pipe_t *_pipe; - zmq::pipe_t *_last_in; - // If true, more outgoing message parts are expected. bool _more_out; diff --git a/deps/zmq/src/dish.cpp b/deps/zmq/src/dish.cpp index d8a4befc168..fc680bf3b73 100644 --- a/deps/zmq/src/dish.cpp +++ b/deps/zmq/src/dish.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -35,8 +8,7 @@ #include "err.hpp" zmq::dish_t::dish_t (class ctx_t *parent_, uint32_t tid_, int sid_) : - socket_base_t (parent_, tid_, sid_, true), - _has_message (false) + socket_base_t (parent_, tid_, sid_, true), _has_message (false) { options.type = ZMQ_DISH; diff --git a/deps/zmq/src/dish.hpp b/deps/zmq/src/dish.hpp index c41ca92e0c2..329082c8228 100644 --- a/deps/zmq/src/dish.hpp +++ b/deps/zmq/src/dish.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_DISH_HPP_INCLUDED__ #define __ZMQ_DISH_HPP_INCLUDED__ diff --git a/deps/zmq/src/dist.cpp b/deps/zmq/src/dist.cpp index 7795bb36c1e..81fc2d3607f 100644 --- a/deps/zmq/src/dist.cpp +++ b/deps/zmq/src/dist.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "dist.hpp" @@ -35,10 +8,7 @@ #include "likely.hpp" zmq::dist_t::dist_t () : - _matching (0), - _active (0), - _eligible (0), - _more (false) + _matching (0), _active (0), _eligible (0), _more (false) { } @@ -64,6 +34,18 @@ void zmq::dist_t::attach (pipe_t *pipe_) } } +bool zmq::dist_t::has_pipe (pipe_t *pipe_) +{ + std::size_t claimed_index = _pipes.index (pipe_); + + // If pipe claims to be outside the available index space it can't be in the distributor. + if (claimed_index >= _pipes.size ()) { + return false; + } + + return _pipes[claimed_index] == pipe_; +} + void zmq::dist_t::match (pipe_t *pipe_) { // If pipe is already matching do nothing. diff --git a/deps/zmq/src/dist.hpp b/deps/zmq/src/dist.hpp index f772a716327..8248f73818d 100644 --- a/deps/zmq/src/dist.hpp +++ b/deps/zmq/src/dist.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_DIST_HPP_INCLUDED__ #define __ZMQ_DIST_HPP_INCLUDED__ @@ -51,6 +24,9 @@ class dist_t // Adds the pipe to the distributor object. void attach (zmq::pipe_t *pipe_); + // Checks if this pipe is present in the distributor. + bool has_pipe (zmq::pipe_t *pipe_); + // Activates pipe that have previously reached high watermark. void activated (zmq::pipe_t *pipe_); diff --git a/deps/zmq/src/encoder.hpp b/deps/zmq/src/encoder.hpp index 84ffe329172..535739aba22 100644 --- a/deps/zmq/src/encoder.hpp +++ b/deps/zmq/src/encoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_ENCODER_HPP_INCLUDED__ #define __ZMQ_ENCODER_HPP_INCLUDED__ diff --git a/deps/zmq/src/endpoint.cpp b/deps/zmq/src/endpoint.cpp index c9ad6d66bd0..59a78e3c074 100644 --- a/deps/zmq/src/endpoint.cpp +++ b/deps/zmq/src/endpoint.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "endpoint.hpp" diff --git a/deps/zmq/src/endpoint.hpp b/deps/zmq/src/endpoint.hpp index 56b7d0e7448..c19b6feae99 100644 --- a/deps/zmq/src/endpoint.hpp +++ b/deps/zmq/src/endpoint.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_ENDPOINT_HPP_INCLUDED__ #define __ZMQ_ENDPOINT_HPP_INCLUDED__ @@ -47,9 +20,7 @@ struct endpoint_uri_pair_t endpoint_uri_pair_t (const std::string &local, const std::string &remote, endpoint_type_t local_type) : - local (local), - remote (remote), - local_type (local_type) + local (local), remote (remote), local_type (local_type) { } diff --git a/deps/zmq/src/epoll.cpp b/deps/zmq/src/epoll.cpp index fc641b74ea1..bcba58458b2 100644 --- a/deps/zmq/src/epoll.cpp +++ b/deps/zmq/src/epoll.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #if defined ZMQ_IOTHREAD_POLLER_USE_EPOLL @@ -131,7 +104,7 @@ void zmq::epoll_t::reset_pollin (handle_t handle_) { check_thread (); poll_entry_t *pe = static_cast (handle_); - pe->ev.events &= ~(static_cast (EPOLLIN)); + pe->ev.events &= ~(static_cast (EPOLLIN)); const int rc = epoll_ctl (_epoll_fd, EPOLL_CTL_MOD, pe->fd, &pe->ev); errno_assert (rc != -1); } @@ -149,7 +122,7 @@ void zmq::epoll_t::reset_pollout (handle_t handle_) { check_thread (); poll_entry_t *pe = static_cast (handle_); - pe->ev.events &= ~(static_cast (EPOLLOUT)); + pe->ev.events &= ~(static_cast (EPOLLOUT)); const int rc = epoll_ctl (_epoll_fd, EPOLL_CTL_MOD, pe->fd, &pe->ev); errno_assert (rc != -1); } @@ -192,6 +165,10 @@ void zmq::epoll_t::loop () const poll_entry_t *const pe = static_cast (ev_buf[i].data.ptr); + if (NULL == pe) + continue; + if (NULL == pe->events) + continue; if (pe->fd == retired_fd) continue; if (ev_buf[i].events & (EPOLLERR | EPOLLHUP)) diff --git a/deps/zmq/src/epoll.hpp b/deps/zmq/src/epoll.hpp index 0e7bad0295f..72cec10e2c9 100644 --- a/deps/zmq/src/epoll.hpp +++ b/deps/zmq/src/epoll.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_EPOLL_HPP_INCLUDED__ #define __ZMQ_EPOLL_HPP_INCLUDED__ @@ -87,7 +60,7 @@ class epoll_t ZMQ_FINAL : public worker_poller_base_t #endif // Main event loop. - void loop (); + void loop () ZMQ_OVERRIDE; // Main epoll file descriptor epoll_fd_t _epoll_fd; diff --git a/deps/zmq/src/err.cpp b/deps/zmq/src/err.cpp index ea2a9b51410..74d062c432b 100644 --- a/deps/zmq/src/err.cpp +++ b/deps/zmq/src/err.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "err.hpp" diff --git a/deps/zmq/src/err.hpp b/deps/zmq/src/err.hpp index 3f3278f8ccc..79b4663d7c9 100644 --- a/deps/zmq/src/err.hpp +++ b/deps/zmq/src/err.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_ERR_HPP_INCLUDED__ #define __ZMQ_ERR_HPP_INCLUDED__ @@ -172,7 +145,7 @@ int wsa_error_to_errno (int errcode_); // Provides convenient way to check whether memory allocation have succeeded. #define alloc_assert(x) \ do { \ - if (unlikely (!x)) { \ + if (unlikely (!(x))) { \ fprintf (stderr, "FATAL ERROR: OUT OF MEMORY (%s:%d)\n", __FILE__, \ __LINE__); \ fflush (stderr); \ diff --git a/deps/zmq/src/fd.hpp b/deps/zmq/src/fd.hpp index 21925ae69c5..e0ca8306f87 100644 --- a/deps/zmq/src/fd.hpp +++ b/deps/zmq/src/fd.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_FD_HPP_INCLUDED__ #define __ZMQ_FD_HPP_INCLUDED__ diff --git a/deps/zmq/src/fq.cpp b/deps/zmq/src/fq.cpp index 2a700977e9b..5b19da60a29 100644 --- a/deps/zmq/src/fq.cpp +++ b/deps/zmq/src/fq.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "fq.hpp" @@ -33,7 +6,7 @@ #include "err.hpp" #include "msg.hpp" -zmq::fq_t::fq_t () : _active (0), _last_in (NULL), _current (0), _more (false) +zmq::fq_t::fq_t () : _active (0), _current (0), _more (false) { } @@ -62,10 +35,6 @@ void zmq::fq_t::pipe_terminated (pipe_t *pipe_) _current = 0; } _pipes.erase (pipe_); - - if (_last_in == pipe_) { - _last_in = NULL; - } } void zmq::fq_t::activated (pipe_t *pipe_) @@ -100,7 +69,6 @@ int zmq::fq_t::recvpipe (msg_t *msg_, pipe_t **pipe_) *pipe_ = _pipes[_current]; _more = (msg_->flags () & msg_t::more) != 0; if (!_more) { - _last_in = _pipes[_current]; _current = (_current + 1) % _active; } return 0; diff --git a/deps/zmq/src/fq.hpp b/deps/zmq/src/fq.hpp index 26724101a83..3ffcefe6214 100644 --- a/deps/zmq/src/fq.hpp +++ b/deps/zmq/src/fq.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_FQ_HPP_INCLUDED__ #define __ZMQ_FQ_HPP_INCLUDED__ @@ -65,11 +38,6 @@ class fq_t // beginning of the pipes array. pipes_t::size_type _active; - // Pointer to the last pipe we received message from. - // NULL when no message has been received or the pipe - // has terminated. - pipe_t *_last_in; - // Index of the next bound pipe to read a message from. pipes_t::size_type _current; diff --git a/deps/zmq/src/gather.cpp b/deps/zmq/src/gather.cpp index 231e7253788..ef9dcdcc299 100644 --- a/deps/zmq/src/gather.cpp +++ b/deps/zmq/src/gather.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" diff --git a/deps/zmq/src/gather.hpp b/deps/zmq/src/gather.hpp index f2de06470b4..8e8cc534de0 100644 --- a/deps/zmq/src/gather.hpp +++ b/deps/zmq/src/gather.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_GATHER_HPP_INCLUDED__ #define __ZMQ_GATHER_HPP_INCLUDED__ diff --git a/deps/zmq/src/generic_mtrie.hpp b/deps/zmq/src/generic_mtrie.hpp index 15dfad63edb..ff0a107207a 100644 --- a/deps/zmq/src/generic_mtrie.hpp +++ b/deps/zmq/src/generic_mtrie.hpp @@ -1,31 +1,4 @@ -/* -Copyright (c) 2018 Contributors as noted in the AUTHORS file - -This file is part of libzmq, the ZeroMQ core engine in C++. - -libzmq is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser General Public License (LGPL) as published -by the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -As a special exception, the Contributors give you permission to link -this library with independent modules to produce an executable, -regardless of the license terms of these independent modules, and to -copy and distribute the resulting executable under terms of your choice, -provided that you also meet, for each linked independent module, the -terms and conditions of the license of that module. An independent -module is a module which is not derived from or based on this library. -If you modify this library, you must extend this exception to your -version of the library. - -libzmq is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_GENERIC_MTRIE_HPP_INCLUDED__ #define __ZMQ_GENERIC_MTRIE_HPP_INCLUDED__ @@ -35,6 +8,7 @@ along with this program. If not, see . #include "macros.hpp" #include "stdint.hpp" +#include "atomic_counter.hpp" namespace zmq { @@ -83,12 +57,18 @@ template class generic_mtrie_t void (*func_) (value_t *value_, Arg arg_), Arg arg_); + // Retrieve the number of prefixes stored in this trie (added - removed) + // Note this is a multithread safe function. + uint32_t num_prefixes () const { return _num_prefixes.get (); } + private: bool is_redundant () const; typedef std::set pipes_t; pipes_t *_pipes; + atomic_counter_t _num_prefixes; + unsigned char _min; unsigned short _count; unsigned short _live_nodes; diff --git a/deps/zmq/src/generic_mtrie_impl.hpp b/deps/zmq/src/generic_mtrie_impl.hpp index 35dae307fa7..cdfb0e3f616 100644 --- a/deps/zmq/src/generic_mtrie_impl.hpp +++ b/deps/zmq/src/generic_mtrie_impl.hpp @@ -1,31 +1,4 @@ -/* -Copyright (c) 2018 Contributors as noted in the AUTHORS file - -This file is part of libzmq, the ZeroMQ core engine in C++. - -libzmq is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser General Public License (LGPL) as published -by the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -As a special exception, the Contributors give you permission to link -this library with independent modules to produce an executable, -regardless of the license terms of these independent modules, and to -copy and distribute the resulting executable under terms of your choice, -provided that you also meet, for each linked independent module, the -terms and conditions of the license of that module. An independent -module is a module which is not derived from or based on this library. -If you modify this library, you must extend this exception to your -version of the library. - -libzmq is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_GENERIC_MTRIE_IMPL_HPP_INCLUDED__ #define __ZMQ_GENERIC_MTRIE_IMPL_HPP_INCLUDED__ @@ -45,10 +18,7 @@ namespace zmq { template generic_mtrie_t::generic_mtrie_t () : - _pipes (0), - _min (0), - _count (0), - _live_nodes (0) + _pipes (0), _num_prefixes (0), _min (0), _count (0), _live_nodes (0) { } @@ -147,6 +117,8 @@ bool generic_mtrie_t::add (prefix_t prefix_, size_t size_, value_t *pipe_) if (!it->_pipes) { it->_pipes = new (std::nothrow) pipes_t; alloc_assert (it->_pipes); + + _num_prefixes.add (1); } it->_pipes->insert (pipe_); @@ -162,12 +134,12 @@ void generic_mtrie_t::rm (value_t *pipe_, Arg arg_, bool call_on_uniq_) { - // This used to be implemented as a non-tail recursive travesal of the trie, + // This used to be implemented as a non-tail recursive traversal of the trie, // which means remote clients controlled the depth of the recursion and the // stack size. // To simulate the non-tail recursion, with post-recursion changes depending on // the result of the recursive call, a stack is used to re-visit the same node - // and operate on it again after children have been visisted. + // and operate on it again after children have been visited. // A boolean is used to record whether the node had already been visited and to // determine if the pre- or post- children visit actions have to be taken. // In the case of a node with (N > 1) children, the node has to be re-visited @@ -404,12 +376,12 @@ template typename generic_mtrie_t::rm_result generic_mtrie_t::rm (prefix_t prefix_, size_t size_, value_t *pipe_) { - // This used to be implemented as a non-tail recursive travesal of the trie, + // This used to be implemented as a non-tail recursive traversal of the trie, // which means remote clients controlled the depth of the recursion and the // stack size. // To simulate the non-tail recursion, with post-recursion changes depending on // the result of the recursive call, a stack is used to re-visit the same node - // and operate on it again after children have been visisted. + // and operate on it again after children have been visited. // A boolean is used to record whether the node had already been visited and to // determine if the pre- or post- children visit actions have to be taken. rm_result ret = not_found; @@ -538,6 +510,11 @@ generic_mtrie_t::rm (prefix_t prefix_, size_t size_, value_t *pipe_) } } + if (ret == last_value_removed) { + zmq_assert (_num_prefixes.get () > 0); + _num_prefixes.sub (1); + } + return ret; } diff --git a/deps/zmq/src/gssapi_client.cpp b/deps/zmq/src/gssapi_client.cpp index 291e9f09bad..0fd23e92698 100644 --- a/deps/zmq/src/gssapi_client.cpp +++ b/deps/zmq/src/gssapi_client.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" diff --git a/deps/zmq/src/gssapi_client.hpp b/deps/zmq/src/gssapi_client.hpp index 18d428c8fa7..f6fd581d8bd 100644 --- a/deps/zmq/src/gssapi_client.hpp +++ b/deps/zmq/src/gssapi_client.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_GSSAPI_CLIENT_HPP_INCLUDED__ #define __ZMQ_GSSAPI_CLIENT_HPP_INCLUDED__ diff --git a/deps/zmq/src/gssapi_mechanism_base.cpp b/deps/zmq/src/gssapi_mechanism_base.cpp index b9ffeec52c2..89b778031d5 100644 --- a/deps/zmq/src/gssapi_mechanism_base.cpp +++ b/deps/zmq/src/gssapi_mechanism_base.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" diff --git a/deps/zmq/src/gssapi_mechanism_base.hpp b/deps/zmq/src/gssapi_mechanism_base.hpp index dec53d0bc5d..d664767694a 100644 --- a/deps/zmq/src/gssapi_mechanism_base.hpp +++ b/deps/zmq/src/gssapi_mechanism_base.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_GSSAPI_MECHANISM_BASE_HPP_INCLUDED__ #define __ZMQ_GSSAPI_MECHANISM_BASE_HPP_INCLUDED__ diff --git a/deps/zmq/src/gssapi_server.cpp b/deps/zmq/src/gssapi_server.cpp index 0a43349a5b4..7e982a9e1d8 100644 --- a/deps/zmq/src/gssapi_server.cpp +++ b/deps/zmq/src/gssapi_server.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" diff --git a/deps/zmq/src/gssapi_server.hpp b/deps/zmq/src/gssapi_server.hpp index 26130115340..89019757323 100644 --- a/deps/zmq/src/gssapi_server.hpp +++ b/deps/zmq/src/gssapi_server.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_GSSAPI_SERVER_HPP_INCLUDED__ #define __ZMQ_GSSAPI_SERVER_HPP_INCLUDED__ diff --git a/deps/zmq/src/i_decoder.hpp b/deps/zmq/src/i_decoder.hpp index e0bcf074513..6fe68092ce2 100644 --- a/deps/zmq/src/i_decoder.hpp +++ b/deps/zmq/src/i_decoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_I_DECODER_HPP_INCLUDED__ #define __ZMQ_I_DECODER_HPP_INCLUDED__ diff --git a/deps/zmq/src/i_encoder.hpp b/deps/zmq/src/i_encoder.hpp index 33ef9dd847b..58ae7d1250c 100644 --- a/deps/zmq/src/i_encoder.hpp +++ b/deps/zmq/src/i_encoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_I_ENCODER_HPP_INCLUDED__ #define __ZMQ_I_ENCODER_HPP_INCLUDED__ diff --git a/deps/zmq/src/i_engine.hpp b/deps/zmq/src/i_engine.hpp index 7d05df8ab6e..1950c39c90a 100644 --- a/deps/zmq/src/i_engine.hpp +++ b/deps/zmq/src/i_engine.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_I_ENGINE_HPP_INCLUDED__ #define __ZMQ_I_ENGINE_HPP_INCLUDED__ diff --git a/deps/zmq/src/i_mailbox.hpp b/deps/zmq/src/i_mailbox.hpp index 7402a219607..a19d7ce23df 100644 --- a/deps/zmq/src/i_mailbox.hpp +++ b/deps/zmq/src/i_mailbox.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_I_MAILBOX_HPP_INCLUDED__ #define __ZMQ_I_MAILBOX_HPP_INCLUDED__ diff --git a/deps/zmq/src/i_poll_events.hpp b/deps/zmq/src/i_poll_events.hpp index 5e70162c913..f3d00590167 100644 --- a/deps/zmq/src/i_poll_events.hpp +++ b/deps/zmq/src/i_poll_events.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_I_POLL_EVENTS_HPP_INCLUDED__ #define __ZMQ_I_POLL_EVENTS_HPP_INCLUDED__ diff --git a/deps/zmq/src/io_object.cpp b/deps/zmq/src/io_object.cpp index aa466c086ea..7a3c6ce3b5a 100644 --- a/deps/zmq/src/io_object.cpp +++ b/deps/zmq/src/io_object.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "io_object.hpp" diff --git a/deps/zmq/src/io_object.hpp b/deps/zmq/src/io_object.hpp index 703af7efc70..a24c6a0956b 100644 --- a/deps/zmq/src/io_object.hpp +++ b/deps/zmq/src/io_object.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_IO_OBJECT_HPP_INCLUDED__ #define __ZMQ_IO_OBJECT_HPP_INCLUDED__ diff --git a/deps/zmq/src/io_thread.cpp b/deps/zmq/src/io_thread.cpp index a2ca950a287..6a6c39d9d40 100644 --- a/deps/zmq/src/io_thread.cpp +++ b/deps/zmq/src/io_thread.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" diff --git a/deps/zmq/src/io_thread.hpp b/deps/zmq/src/io_thread.hpp index 65e276d97b5..afbc05fd2ee 100644 --- a/deps/zmq/src/io_thread.hpp +++ b/deps/zmq/src/io_thread.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_IO_THREAD_HPP_INCLUDED__ #define __ZMQ_IO_THREAD_HPP_INCLUDED__ diff --git a/deps/zmq/src/ip.cpp b/deps/zmq/src/ip.cpp index d150da76a67..98804e8c6c0 100644 --- a/deps/zmq/src/ip.cpp +++ b/deps/zmq/src/ip.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "ip.hpp" @@ -237,6 +210,9 @@ void zmq::set_socket_priority (fd_t s_, int priority_) setsockopt (s_, SOL_SOCKET, SO_PRIORITY, reinterpret_cast (&priority_), sizeof (priority_)); errno_assert (rc == 0); +#else + LIBZMQ_UNUSED (s_); + LIBZMQ_UNUSED (priority_); #endif } @@ -307,7 +283,7 @@ bool zmq::initialize_network () #endif #ifdef ZMQ_HAVE_WINDOWS - // Intialise Windows sockets. Note that WSAStartup can be called multiple + // Initialise Windows sockets. Note that WSAStartup can be called multiple // times given that WSACleanup will be called for each WSAStartup. const WORD version_requested = MAKEWORD (2, 2); @@ -577,6 +553,11 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_) int rc = 0; int saved_errno = 0; + // It appears that a lack of runtime AF_UNIX support + // can fail in more than one way. + // At least: open_socket can fail or later in bind + bool ipc_fallback_on_tcpip = true; + // Create a listening socket. const SOCKET listener = open_socket (AF_UNIX, SOCK_STREAM, 0); if (listener == retired_fd) { @@ -599,6 +580,9 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_) errno = wsa_error_to_errno (WSAGetLastError ()); goto error_closelistener; } + // if we got here, ipc should be working, + // so raise any remaining errors + ipc_fallback_on_tcpip = false; // Listen for incoming connections. rc = listen (listener, 1); @@ -665,8 +649,12 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_) filename.clear (); } - errno = saved_errno; + // ipc failed due to lack of AF_UNIX support, fallback on tcpip + if (ipc_fallback_on_tcpip) { + goto try_tcpip; + } + errno = saved_errno; return -1; try_tcpip: @@ -868,24 +856,48 @@ void zmq::assert_success_or_recoverable (zmq::fd_t s_, int rc_) } #ifdef ZMQ_HAVE_IPC + +#if defined ZMQ_HAVE_WINDOWS +char *widechar_to_utf8 (const wchar_t *widestring) +{ + int nch, n; + char *utf8 = 0; + nch = WideCharToMultiByte (CP_UTF8, 0, widestring, -1, 0, 0, NULL, NULL); + if (nch > 0) { + utf8 = (char *) malloc ((nch + 1) * sizeof (char)); + n = WideCharToMultiByte (CP_UTF8, 0, widestring, -1, utf8, nch, NULL, + NULL); + utf8[nch] = 0; + } + return utf8; +} +#endif + int zmq::create_ipc_wildcard_address (std::string &path_, std::string &file_) { #if defined ZMQ_HAVE_WINDOWS - char buffer[MAX_PATH]; + wchar_t buffer[MAX_PATH]; { - const errno_t rc = tmpnam_s (buffer); + const errno_t rc = _wtmpnam_s (buffer); errno_assert (rc == 0); } // TODO or use CreateDirectoryA and specify permissions? - const int rc = _mkdir (buffer); + const int rc = _wmkdir (buffer); if (rc != 0) { return -1; } - path_.assign (buffer); + char *tmp = widechar_to_utf8 (buffer); + if (tmp == 0) { + return -1; + } + + path_.assign (tmp); file_ = path_ + "/socket"; + + free (tmp); #else std::string tmp_path; diff --git a/deps/zmq/src/ip.hpp b/deps/zmq/src/ip.hpp index 34cc06c4197..9ec54fc6f51 100644 --- a/deps/zmq/src/ip.hpp +++ b/deps/zmq/src/ip.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_IP_HPP_INCLUDED__ #define __ZMQ_IP_HPP_INCLUDED__ @@ -77,7 +50,7 @@ void make_socket_noninheritable (fd_t sock_); // Asserts that: // - an internal 0MQ error did not occur, -// - and, if a socket error occured, it can be recovered from. +// - and, if a socket error occurred, it can be recovered from. void assert_success_or_recoverable (fd_t s_, int rc_); #ifdef ZMQ_HAVE_IPC diff --git a/deps/zmq/src/ip_resolver.hpp b/deps/zmq/src/ip_resolver.hpp index e60f6356ec9..c6f28fba13d 100644 --- a/deps/zmq/src/ip_resolver.hpp +++ b/deps/zmq/src/ip_resolver.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2018 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_IP_RESOLVER_HPP_INCLUDED__ #define __ZMQ_IP_RESOLVER_HPP_INCLUDED__ diff --git a/deps/zmq/src/ipc_address.cpp b/deps/zmq/src/ipc_address.cpp index f1f56516f65..d06771d3771 100644 --- a/deps/zmq/src/ipc_address.cpp +++ b/deps/zmq/src/ipc_address.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "compat.hpp" diff --git a/deps/zmq/src/ipc_address.hpp b/deps/zmq/src/ipc_address.hpp index 4c2277d3946..422c271127a 100644 --- a/deps/zmq/src/ipc_address.hpp +++ b/deps/zmq/src/ipc_address.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_IPC_ADDRESS_HPP_INCLUDED__ #define __ZMQ_IPC_ADDRESS_HPP_INCLUDED__ diff --git a/deps/zmq/src/ipc_connecter.cpp b/deps/zmq/src/ipc_connecter.cpp index 8dd01f02a59..3f988745e72 100644 --- a/deps/zmq/src/ipc_connecter.cpp +++ b/deps/zmq/src/ipc_connecter.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "ipc_connecter.hpp" diff --git a/deps/zmq/src/ipc_connecter.hpp b/deps/zmq/src/ipc_connecter.hpp index 1f85c8934fd..ec6dc922e63 100644 --- a/deps/zmq/src/ipc_connecter.hpp +++ b/deps/zmq/src/ipc_connecter.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __IPC_CONNECTER_HPP_INCLUDED__ #define __IPC_CONNECTER_HPP_INCLUDED__ diff --git a/deps/zmq/src/ipc_listener.cpp b/deps/zmq/src/ipc_listener.cpp index fc5bc51aec7..50126040d2b 100644 --- a/deps/zmq/src/ipc_listener.cpp +++ b/deps/zmq/src/ipc_listener.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "ipc_listener.hpp" @@ -78,8 +51,7 @@ zmq::ipc_listener_t::ipc_listener_t (io_thread_t *io_thread_, socket_base_t *socket_, const options_t &options_) : - stream_listener_base_t (io_thread_, socket_, options_), - _has_file (false) + stream_listener_base_t (io_thread_, socket_, options_), _has_file (false) { } diff --git a/deps/zmq/src/ipc_listener.hpp b/deps/zmq/src/ipc_listener.hpp index 85c7d41eade..5983b197127 100644 --- a/deps/zmq/src/ipc_listener.hpp +++ b/deps/zmq/src/ipc_listener.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_IPC_LISTENER_HPP_INCLUDED__ #define __ZMQ_IPC_LISTENER_HPP_INCLUDED__ diff --git a/deps/zmq/src/kqueue.cpp b/deps/zmq/src/kqueue.cpp index 53d82ac4f81..eb1812ba371 100644 --- a/deps/zmq/src/kqueue.cpp +++ b/deps/zmq/src/kqueue.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "kqueue.hpp" @@ -46,9 +19,9 @@ #include "i_poll_events.hpp" #include "likely.hpp" -// NetBSD defines (struct kevent).udata as intptr_t, everyone else -// as void *. -#if defined ZMQ_HAVE_NETBSD +// NetBSD up to version 9 defines (struct kevent).udata as intptr_t, +// everyone else as void *. +#if defined ZMQ_HAVE_NETBSD && defined(ZMQ_NETBSD_KEVENT_UDATA_INTPTR_T) #define kevent_udata_t intptr_t #else #define kevent_udata_t void * diff --git a/deps/zmq/src/kqueue.hpp b/deps/zmq/src/kqueue.hpp index 002fbab38ce..721dd62a1bc 100644 --- a/deps/zmq/src/kqueue.hpp +++ b/deps/zmq/src/kqueue.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_KQUEUE_HPP_INCLUDED__ #define __ZMQ_KQUEUE_HPP_INCLUDED__ diff --git a/deps/zmq/src/lb.cpp b/deps/zmq/src/lb.cpp index e766b4f2f06..cd96bdcb972 100644 --- a/deps/zmq/src/lb.cpp +++ b/deps/zmq/src/lb.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2018 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "lb.hpp" diff --git a/deps/zmq/src/lb.hpp b/deps/zmq/src/lb.hpp index b206967bc27..3eba3a37b2c 100644 --- a/deps/zmq/src/lb.hpp +++ b/deps/zmq/src/lb.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_LB_HPP_INCLUDED__ #define __ZMQ_LB_HPP_INCLUDED__ diff --git a/deps/zmq/src/likely.hpp b/deps/zmq/src/likely.hpp index d6cb14d7042..c20a7baf2eb 100644 --- a/deps/zmq/src/likely.hpp +++ b/deps/zmq/src/likely.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_LIKELY_HPP_INCLUDED__ #define __ZMQ_LIKELY_HPP_INCLUDED__ diff --git a/deps/zmq/src/mailbox.cpp b/deps/zmq/src/mailbox.cpp index 2fb0fe0cad8..7b26df87bdf 100644 --- a/deps/zmq/src/mailbox.cpp +++ b/deps/zmq/src/mailbox.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "mailbox.hpp" diff --git a/deps/zmq/src/mailbox.hpp b/deps/zmq/src/mailbox.hpp index 0cd92d208f5..cb150f03722 100644 --- a/deps/zmq/src/mailbox.hpp +++ b/deps/zmq/src/mailbox.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_MAILBOX_HPP_INCLUDED__ #define __ZMQ_MAILBOX_HPP_INCLUDED__ @@ -58,7 +31,10 @@ class mailbox_t ZMQ_FINAL : public i_mailbox // close the file descriptors in the signaller. This is used in a forked // child process to close the file descriptors so that they do not interfere // with the context in the parent process. - void forked () ZMQ_FINAL { _signaler.forked (); } + void forked () ZMQ_FINAL + { + _signaler.forked (); + } #endif private: diff --git a/deps/zmq/src/mailbox_safe.cpp b/deps/zmq/src/mailbox_safe.cpp index f49fa957abb..575ee074eed 100644 --- a/deps/zmq/src/mailbox_safe.cpp +++ b/deps/zmq/src/mailbox_safe.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "mailbox_safe.hpp" diff --git a/deps/zmq/src/mailbox_safe.hpp b/deps/zmq/src/mailbox_safe.hpp index 04dbf140933..fac2d64045f 100644 --- a/deps/zmq/src/mailbox_safe.hpp +++ b/deps/zmq/src/mailbox_safe.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_MAILBOX_SAFE_HPP_INCLUDED__ #define __ZMQ_MAILBOX_SAFE_HPP_INCLUDED__ diff --git a/deps/zmq/src/mechanism.cpp b/deps/zmq/src/mechanism.cpp index 0d46c11eac8..07127775e94 100644 --- a/deps/zmq/src/mechanism.cpp +++ b/deps/zmq/src/mechanism.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include diff --git a/deps/zmq/src/mechanism.hpp b/deps/zmq/src/mechanism.hpp index 13f0ffbe39a..066e9bc21e9 100644 --- a/deps/zmq/src/mechanism.hpp +++ b/deps/zmq/src/mechanism.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_MECHANISM_HPP_INCLUDED__ #define __ZMQ_MECHANISM_HPP_INCLUDED__ diff --git a/deps/zmq/src/mechanism_base.cpp b/deps/zmq/src/mechanism_base.cpp index d51b3695a5a..a8ecece4648 100644 --- a/deps/zmq/src/mechanism_base.cpp +++ b/deps/zmq/src/mechanism_base.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" @@ -34,8 +7,7 @@ zmq::mechanism_base_t::mechanism_base_t (session_base_t *const session_, const options_t &options_) : - mechanism_t (options_), - session (session_) + mechanism_t (options_), session (session_) { } diff --git a/deps/zmq/src/mechanism_base.hpp b/deps/zmq/src/mechanism_base.hpp index 767f1803c5d..88ed1be2296 100644 --- a/deps/zmq/src/mechanism_base.hpp +++ b/deps/zmq/src/mechanism_base.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_MECHANISM_BASE_HPP_INCLUDED__ #define __ZMQ_MECHANISM_BASE_HPP_INCLUDED__ diff --git a/deps/zmq/src/metadata.cpp b/deps/zmq/src/metadata.cpp index 45a16a60031..b569344a4b0 100644 --- a/deps/zmq/src/metadata.cpp +++ b/deps/zmq/src/metadata.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "metadata.hpp" diff --git a/deps/zmq/src/metadata.hpp b/deps/zmq/src/metadata.hpp index b8c145131d6..a5fcd6ecb33 100644 --- a/deps/zmq/src/metadata.hpp +++ b/deps/zmq/src/metadata.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_METADATA_HPP_INCLUDED__ #define __ZMQ_METADATA_HPP_INCLUDED__ diff --git a/deps/zmq/src/msg.cpp b/deps/zmq/src/msg.cpp index 2116d1e40c7..a92e432154d 100644 --- a/deps/zmq/src/msg.cpp +++ b/deps/zmq/src/msg.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "compat.hpp" diff --git a/deps/zmq/src/msg.hpp b/deps/zmq/src/msg.hpp index d956b2ac819..e9755b63f98 100644 --- a/deps/zmq/src/msg.hpp +++ b/deps/zmq/src/msg.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_MSG_HPP_INCLUDE__ #define __ZMQ_MSG_HPP_INCLUDE__ @@ -46,7 +19,7 @@ // Note that it has to be declared as "C" so that it is the same as // zmq_free_fn defined in zmq.h. extern "C" { -typedef void(msg_free_fn) (void *data_, void *hint_); +typedef void (msg_free_fn) (void *data_, void *hint_); } namespace zmq diff --git a/deps/zmq/src/mtrie.cpp b/deps/zmq/src/mtrie.cpp index 30a84e32430..92152b5080a 100644 --- a/deps/zmq/src/mtrie.cpp +++ b/deps/zmq/src/mtrie.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "mtrie.hpp" diff --git a/deps/zmq/src/mtrie.hpp b/deps/zmq/src/mtrie.hpp index b5ca3ac0f6a..b31478f1bfa 100644 --- a/deps/zmq/src/mtrie.hpp +++ b/deps/zmq/src/mtrie.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_MTRIE_HPP_INCLUDED__ #define __ZMQ_MTRIE_HPP_INCLUDED__ diff --git a/deps/zmq/src/mutex.hpp b/deps/zmq/src/mutex.hpp index 8ff02269c76..f0c7efaa512 100644 --- a/deps/zmq/src/mutex.hpp +++ b/deps/zmq/src/mutex.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_MUTEX_HPP_INCLUDED__ #define __ZMQ_MUTEX_HPP_INCLUDED__ @@ -35,7 +8,7 @@ // Mutex class encapsulates OS mutex in a platform-independent way. -#ifdef ZMQ_HAVE_WINDOWS +#if defined(ZMQ_HAVE_WINDOWS) && !defined(ZMQ_USE_CV_IMPL_PTHREADS) #include "windows.hpp" diff --git a/deps/zmq/src/norm_engine.cpp b/deps/zmq/src/norm_engine.cpp index f2166fdc9b3..1e3ae179ca6 100644 --- a/deps/zmq/src/norm_engine.cpp +++ b/deps/zmq/src/norm_engine.cpp @@ -6,9 +6,26 @@ #if defined ZMQ_HAVE_NORM #include "norm_engine.hpp" +#ifdef ZMQ_USE_NORM_SOCKET_WRAPPER +#include "ip.hpp" +#endif + #include "session_base.hpp" #include "v2_protocol.hpp" + +#ifdef ZMQ_USE_NORM_SOCKET_WRAPPER + +struct norm_wrapper_thread_args_t +{ + NormDescriptor norm_descriptor; + SOCKET wrapper_write_fd; + NormInstanceHandle norm_instance_handle; +}; + +DWORD WINAPI normWrapperThread (LPVOID lpParam); +#endif + zmq::norm_engine_t::norm_engine_t (io_thread_t *parent_, const options_t &options_) : io_object_t (parent_), @@ -114,14 +131,9 @@ int zmq::norm_engine_t::init (const char *network_, bool send, bool recv) return -1; } // There's many other useful NORM options that could be applied here - if (NormIsUnicastAddress (addr)) { - NormSetDefaultUnicastNack (norm_session, true); - } else { + if (!NormIsUnicastAddress (addr)) { // These only apply for multicast sessions - //NormSetTTL(norm_session, options.multicast_hops); // ZMQ default is 1 - NormSetTTL ( - norm_session, - 255); // since the ZMQ_MULTICAST_HOPS socket option isn't well-supported + NormSetTTL (norm_session, options.multicast_hops); NormSetRxPortReuse ( norm_session, true); // port reuse doesn't work for non-connected unicast @@ -133,13 +145,31 @@ int zmq::norm_engine_t::init (const char *network_, bool send, bool recv) NormSetMulticastInterface (norm_session, ifacePtr); } } + if (NormIsUnicastAddress (addr) || options.norm_unicast_nacks) { + NormSetDefaultUnicastNack (norm_session, true); + } + // Set TOS but check TOS ECN bit for CCE modes + if ((options.norm_mode == ZMQ_NORM_CCE + || options.norm_mode == ZMQ_NORM_CCE_ECNONLY) + && (options.tos % 4 == 0)) { + // ECN Capable Transport not set, so set it + NormSetTOS (norm_session, options.tos + 1); + } else if ((options.norm_mode == ZMQ_NORM_CCE + || options.norm_mode == ZMQ_NORM_CCE_ECNONLY) + && (options.tos % 4 == 3)) { + // Congestion Experienced is an invalid setting, remove one of the bits + NormSetTOS (norm_session, options.tos - 1); + } else { + NormSetTOS (norm_session, options.tos); + } if (recv) { // The alternative NORM_SYNC_CURRENT here would provide "instant" // receiver sync to the sender's _current_ message transmission. // NORM_SYNC_STREAM tries to get everything the sender has cached/buffered NormSetDefaultSyncPolicy (norm_session, NORM_SYNC_STREAM); - if (!NormStartReceiver (norm_session, 2 * 1024 * 1024)) { + if (!NormStartReceiver ( + norm_session, (unsigned long) options.norm_buffer_size * 1024)) { // errno set by whatever failed int savedErrno = errno; NormDestroyInstance (norm_instance); // session gets closed, too @@ -152,11 +182,22 @@ int zmq::norm_engine_t::init (const char *network_, bool send, bool recv) } if (send) { + // Handle invalid settings -- num_parity must be >= num_autoparity (which has a default of 0) + unsigned char numparity = + (options.norm_num_parity >= options.norm_num_autoparity + ? options.norm_num_parity + : options.norm_num_autoparity); + // Handle invalid settings -- block size must be > effective num_parity (which is <255) + unsigned char blocksize = + (options.norm_block_size > numparity ? options.norm_block_size + : numparity + 1); // Pick a random sender instance id (aka norm sender session id) NormSessionId instanceId = NormGetRandomSessionId (); // TBD - provide "options" for some NORM sender parameters - if (!NormStartSender (norm_session, instanceId, 2 * 1024 * 1024, 1400, - 16, 4)) { + if (!NormStartSender (norm_session, instanceId, + (unsigned long) options.norm_buffer_size * 1024, + options.norm_segment_size, blocksize, + numparity)) { // errno set by whatever failed int savedErrno = errno; NormDestroyInstance (norm_instance); // session gets closed, too @@ -165,12 +206,29 @@ int zmq::norm_engine_t::init (const char *network_, bool send, bool recv) errno = savedErrno; return -1; } - NormSetCongestionControl (norm_session, true); + // Handle NORM mode + if (options.norm_mode == ZMQ_NORM_FIXED) { + NormSetTxRate (norm_session, (double) options.rate * 1000); + } else { + NormSetCongestionControl (norm_session, true); + if (options.norm_mode != ZMQ_NORM_CC) { + NormSetEcnSupport ( + norm_session, + ((options.norm_mode == ZMQ_NORM_CCE) + || (options.norm_mode == ZMQ_NORM_CCE_ECNONLY)), + options.norm_mode == ZMQ_NORM_CCE_ECNONLY, + options.norm_mode == ZMQ_NORM_CCL); + } + } + if (options.norm_num_autoparity > 0) { + NormSetAutoParity (norm_session, options.norm_num_autoparity); + } norm_tx_ready = true; is_sender = true; if (NORM_OBJECT_INVALID - == (norm_tx_stream = - NormStreamOpen (norm_session, 2 * 1024 * 1024))) { + == (norm_tx_stream = NormStreamOpen ( + norm_session, + (unsigned long) options.norm_buffer_size * 1024))) { // errno set by whatever failed int savedErrno = errno; NormDestroyInstance (norm_instance); // session gets closed, too @@ -179,6 +237,8 @@ int zmq::norm_engine_t::init (const char *network_, bool send, bool recv) errno = savedErrno; return -1; } + // NORM Stream options + NormStreamSetPushEnable (norm_tx_stream, options.norm_push_enable); } //NormSetMessageTrace(norm_session, true); @@ -219,6 +279,20 @@ void zmq::norm_engine_t::shutdown () void zmq::norm_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_) { +#ifdef ZMQ_USE_NORM_SOCKET_WRAPPER + norm_wrapper_thread_args_t *threadArgs = new norm_wrapper_thread_args_t; + int rc = make_fdpair (&wrapper_read_fd, &threadArgs->wrapper_write_fd); + errno_assert (rc != -1); + + threadArgs->norm_descriptor = NormGetDescriptor (norm_instance); + threadArgs->norm_instance_handle = norm_instance; + norm_descriptor_handle = add_fd (wrapper_read_fd); +#else + fd_t normDescriptor = NormGetDescriptor (norm_instance); + norm_descriptor_handle = add_fd (normDescriptor); +#endif + // Set POLLIN for notification of pending NormEvents + set_pollin (norm_descriptor_handle); // TBD - we may assign the NORM engine to an io_thread in the future??? zmq_session = session_; if (is_sender) @@ -226,20 +300,30 @@ void zmq::norm_engine_t::plug (io_thread_t *io_thread_, if (is_receiver) zmq_input_ready = true; - fd_t normDescriptor = NormGetDescriptor (norm_instance); - norm_descriptor_handle = add_fd (normDescriptor); - // Set POLLIN for notification of pending NormEvents - set_pollin (norm_descriptor_handle); if (is_sender) send_data (); +#ifdef ZMQ_USE_NORM_SOCKET_WRAPPER + wrapper_thread_handle = CreateThread (NULL, 0, normWrapperThread, + threadArgs, 0, &wrapper_thread_id); +#endif + } // end zmq::norm_engine_t::init() void zmq::norm_engine_t::unplug () { rm_fd (norm_descriptor_handle); - +#ifdef ZMQ_USE_NORM_SOCKET_WRAPPER + PostThreadMessage (wrapper_thread_id, WM_QUIT, (WPARAM) NULL, + (LPARAM) NULL); + WaitForSingleObject (wrapper_thread_handle, INFINITE); + DWORD exitCode; + GetExitCodeThread (wrapper_thread_handle, &exitCode); + zmq_assert (exitCode != -1); + int rc = closesocket (wrapper_read_fd); + errno_assert (rc != -1); +#endif zmq_session = NULL; } // end zmq::norm_engine_t::unplug() @@ -329,11 +413,17 @@ void zmq::norm_engine_t::in_event () { // This means a NormEvent is pending, so call NormGetNextEvent() and handle NormEvent event; +#ifdef ZMQ_USE_NORM_SOCKET_WRAPPER + int rc = recv (wrapper_read_fd, reinterpret_cast (&event), + sizeof (event), 0); + errno_assert (rc == sizeof (event)); +#else if (!NormGetNextEvent (norm_instance, &event)) { // NORM has died before we unplugged?! zmq_assert (false); return; } +#endif switch (event.type) { case NORM_TX_QUEUE_VACANCY: @@ -467,8 +557,7 @@ void zmq::norm_engine_t::recv_data (NormObjectHandle object) char syncFlag; unsigned int numBytes = 1; if (!NormStreamRead (stream, &syncFlag, &numBytes)) { - // broken stream (shouldn't happen after seek msg start?) - zmq_assert (false); + // broken stream (can happen on late-joining subscriber) continue; } if (0 == numBytes) { @@ -718,4 +807,60 @@ const zmq::endpoint_uri_pair_t &zmq::norm_engine_t::get_endpoint () const return _empty_endpoint; } + +#ifdef ZMQ_USE_NORM_SOCKET_WRAPPER +#include +DWORD WINAPI normWrapperThread (LPVOID lpParam) +{ + norm_wrapper_thread_args_t *norm_wrapper_thread_args = + (norm_wrapper_thread_args_t *) lpParam; + NormEvent message; + DWORD waitRc; + DWORD exitCode = 0; + int rc; + + for (;;) { + // wait for norm event or message + waitRc = MsgWaitForMultipleObjectsEx ( + 1, &norm_wrapper_thread_args->norm_descriptor, INFINITE, + QS_ALLPOSTMESSAGE, 0); + + // Check if norm event + if (waitRc == WAIT_OBJECT_0) { + // Process norm event + if (!NormGetNextEvent ( + norm_wrapper_thread_args->norm_instance_handle, &message)) { + exitCode = -1; + break; + } + rc = + send (norm_wrapper_thread_args->wrapper_write_fd, + reinterpret_cast (&message), sizeof (message), 0); + errno_assert (rc != -1); + // Check if message + } else if (waitRc == WAIT_OBJECT_0 + 1) { + // Exit if WM_QUIT is received otherwise do nothing + MSG message; + GetMessage (&message, 0, 0, 0); + if (message.message == WM_QUIT) { + break; + } else { + // do nothing + } + // Otherwise an error occurred + } else { + exitCode = -1; + break; + } + } + // Free resources + rc = closesocket (norm_wrapper_thread_args->wrapper_write_fd); + free (norm_wrapper_thread_args); + errno_assert (rc != -1); + + return exitCode; +} + +#endif + #endif // ZMQ_HAVE_NORM diff --git a/deps/zmq/src/norm_engine.hpp b/deps/zmq/src/norm_engine.hpp index c5ae9e84b40..049d716df49 100644 --- a/deps/zmq/src/norm_engine.hpp +++ b/deps/zmq/src/norm_engine.hpp @@ -4,6 +4,11 @@ #if defined ZMQ_HAVE_NORM +#if defined(ZMQ_HAVE_WINDOWS) && defined(ZMQ_IOTHREAD_POLLER_USE_EPOLL) +#define ZMQ_USE_NORM_SOCKET_WRAPPER +#endif + + #include "io_object.hpp" #include "i_engine.hpp" #include "options.hpp" @@ -186,6 +191,12 @@ class norm_engine_t ZMQ_FINAL : public io_object_t, public i_engine NormRxStreamState::List msg_ready_list; // rx streams w/ msg ready for push to zmq +#ifdef ZMQ_USE_NORM_SOCKET_WRAPPER + fd_t + wrapper_read_fd; // filedescriptor used to read norm events through the wrapper + DWORD wrapper_thread_id; + HANDLE wrapper_thread_handle; +#endif }; // end class norm_engine_t } diff --git a/deps/zmq/src/null_mechanism.cpp b/deps/zmq/src/null_mechanism.cpp index 4c1fd2a4edd..ced270cde35 100644 --- a/deps/zmq/src/null_mechanism.cpp +++ b/deps/zmq/src/null_mechanism.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" diff --git a/deps/zmq/src/null_mechanism.hpp b/deps/zmq/src/null_mechanism.hpp index 3ea31649e9d..d22874f329d 100644 --- a/deps/zmq/src/null_mechanism.hpp +++ b/deps/zmq/src/null_mechanism.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_NULL_MECHANISM_HPP_INCLUDED__ #define __ZMQ_NULL_MECHANISM_HPP_INCLUDED__ diff --git a/deps/zmq/src/object.cpp b/deps/zmq/src/object.cpp index ba3558f664c..a04cea5f38d 100644 --- a/deps/zmq/src/object.cpp +++ b/deps/zmq/src/object.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -44,8 +17,7 @@ zmq::object_t::object_t (ctx_t *ctx_, uint32_t tid_) : _ctx (ctx_), _tid (tid_) } zmq::object_t::object_t (object_t *parent_) : - _ctx (parent_->_ctx), - _tid (parent_->_tid) + _ctx (parent_->_ctx), _tid (parent_->_tid) { } diff --git a/deps/zmq/src/object.hpp b/deps/zmq/src/object.hpp index b672b0d86e0..1fe06357ca5 100644 --- a/deps/zmq/src/object.hpp +++ b/deps/zmq/src/object.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_OBJECT_HPP_INCLUDED__ #define __ZMQ_OBJECT_HPP_INCLUDED__ diff --git a/deps/zmq/src/options.cpp b/deps/zmq/src/options.cpp index 1b7d2175492..acaeb84a715 100644 --- a/deps/zmq/src/options.cpp +++ b/deps/zmq/src/options.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -254,7 +227,18 @@ zmq::options_t::options_t () : hello_msg (), can_send_hello_msg (false), disconnect_msg (), - can_recv_disconnect_msg (false) + can_recv_disconnect_msg (false), + hiccup_msg (), + can_recv_hiccup_msg (false), + norm_mode (ZMQ_NORM_CC), + norm_unicast_nacks (false), + norm_buffer_size (2048), + norm_segment_size (1400), + norm_block_size (16), + norm_num_parity (4), + norm_num_autoparity (0), + norm_push_enable (false), + busy_poll (0) { memset (curve_public_key, 0, CURVE_KEYSIZE); memset (curve_secret_key, 0, CURVE_KEYSIZE); @@ -802,6 +786,12 @@ int zmq::options_t::setsockopt (int option_, } break; + case ZMQ_BUSY_POLL: + if (is_int) { + busy_poll = value; + return 0; + } + break; #ifdef ZMQ_HAVE_WSS case ZMQ_WSS_KEY_PEM: // TODO: check if valid certificate @@ -823,6 +813,58 @@ int zmq::options_t::setsockopt (int option_, &wss_trust_system); #endif +#ifdef ZMQ_HAVE_NORM + case ZMQ_NORM_MODE: + if (is_int && value >= 0 && value <= 4) { + norm_mode = value; + return 0; + } + break; + + case ZMQ_NORM_UNICAST_NACK: + return do_setsockopt_int_as_bool_strict (optval_, optvallen_, + &norm_unicast_nacks); + + case ZMQ_NORM_BUFFER_SIZE: + if (is_int && value > 0) { + norm_buffer_size = value; + return 0; + } + break; + + case ZMQ_NORM_SEGMENT_SIZE: + if (is_int && value > 0) { + norm_segment_size = value; + return 0; + } + break; + + case ZMQ_NORM_BLOCK_SIZE: + if (is_int && value > 0 && value <= 255) { + norm_block_size = value; + return 0; + } + break; + + case ZMQ_NORM_NUM_PARITY: + if (is_int && value >= 0 && value < 255) { + norm_num_parity = value; + return 0; + } + break; + + case ZMQ_NORM_NUM_AUTOPARITY: + if (is_int && value >= 0 && value < 255) { + norm_num_autoparity = value; + return 0; + } + break; + + case ZMQ_NORM_PUSH: + return do_setsockopt_int_as_bool_strict (optval_, optvallen_, + &norm_push_enable); +#endif //ZMQ_HAVE_NORM + case ZMQ_HELLO_MSG: if (optvallen_ > 0) { unsigned char *bytes = (unsigned char *) optval_; @@ -852,6 +894,18 @@ int zmq::options_t::setsockopt (int option_, } break; + case ZMQ_HICCUP_MSG: + if (optvallen_ > 0) { + unsigned char *bytes = (unsigned char *) optval_; + hiccup_msg = + std::vector (bytes, bytes + optvallen_); + } else { + hiccup_msg = std::vector (); + } + + return 0; + + #endif default: @@ -1285,6 +1339,71 @@ int zmq::options_t::getsockopt (int option_, return 0; } break; + + case ZMQ_BUSY_POLL: + if (is_int) { + *value = busy_poll; + } + break; + +#ifdef ZMQ_HAVE_NORM + case ZMQ_NORM_MODE: + if (is_int) { + *value = norm_mode; + return 0; + } + break; + + case ZMQ_NORM_UNICAST_NACK: + if (is_int) { + *value = norm_unicast_nacks; + return 0; + } + break; + + case ZMQ_NORM_BUFFER_SIZE: + if (is_int) { + *value = norm_buffer_size; + return 0; + } + break; + + case ZMQ_NORM_SEGMENT_SIZE: + if (is_int) { + *value = norm_segment_size; + return 0; + } + break; + + case ZMQ_NORM_BLOCK_SIZE: + if (is_int) { + *value = norm_block_size; + return 0; + } + break; + + case ZMQ_NORM_NUM_PARITY: + if (is_int) { + *value = norm_num_parity; + return 0; + } + break; + + case ZMQ_NORM_NUM_AUTOPARITY: + if (is_int) { + *value = norm_num_autoparity; + return 0; + } + break; + + case ZMQ_NORM_PUSH: + if (is_int) { + *value = norm_push_enable; + return 0; + } + break; +#endif //ZMQ_HAVE_NORM + #endif diff --git a/deps/zmq/src/options.hpp b/deps/zmq/src/options.hpp index 6aa8c321203..fc06cbc908a 100644 --- a/deps/zmq/src/options.hpp +++ b/deps/zmq/src/options.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_OPTIONS_HPP_INCLUDED__ #define __ZMQ_OPTIONS_HPP_INCLUDED__ @@ -128,7 +101,7 @@ struct options_t int reconnect_ivl; // Maximum interval between attempts to reconnect, in milliseconds. - // Default 0 (unused) + // Default 0ms (meaning maximum interval is disabled) int reconnect_ivl_max; // Maximum backlog for pending connections. @@ -167,7 +140,7 @@ struct options_t std::string socks_proxy_address; // Credentials for SOCKS proxy. - // Conneciton method will be basic auth if username + // Connection method will be basic auth if username // is not empty, no auth otherwise. std::string socks_proxy_username; std::string socks_proxy_password; @@ -308,6 +281,23 @@ struct options_t // Disconnect msg std::vector disconnect_msg; bool can_recv_disconnect_msg; + + // Hiccup msg + std::vector hiccup_msg; + bool can_recv_hiccup_msg; + + // NORM Options + int norm_mode; + bool norm_unicast_nacks; + int norm_buffer_size; + int norm_segment_size; + int norm_block_size; + int norm_num_parity; + int norm_num_autoparity; + bool norm_push_enable; + + // This option removes several delays caused by scheduling, interrupts and context switching. + int busy_poll; }; inline bool get_effective_conflate_option (const options_t &options) diff --git a/deps/zmq/src/own.cpp b/deps/zmq/src/own.cpp index f74824bb218..b70c29d8ddc 100644 --- a/deps/zmq/src/own.cpp +++ b/deps/zmq/src/own.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "own.hpp" @@ -74,7 +47,7 @@ void zmq::own_t::process_seqnum () // Catch up with counter of processed commands. _processed_seqnum++; - // We may have catched up and still have pending terms acks. + // We may have caught up and still have pending terms acks. check_term_acks (); } diff --git a/deps/zmq/src/own.hpp b/deps/zmq/src/own.hpp index 21463fe3218..fa8e2b800b2 100644 --- a/deps/zmq/src/own.hpp +++ b/deps/zmq/src/own.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_OWN_HPP_INCLUDED__ #define __ZMQ_OWN_HPP_INCLUDED__ diff --git a/deps/zmq/src/pair.cpp b/deps/zmq/src/pair.cpp index f3bfe34b88a..5b3806b6d71 100644 --- a/deps/zmq/src/pair.cpp +++ b/deps/zmq/src/pair.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -35,9 +8,7 @@ #include "msg.hpp" zmq::pair_t::pair_t (class ctx_t *parent_, uint32_t tid_, int sid_) : - socket_base_t (parent_, tid_, sid_), - _pipe (NULL), - _last_in (NULL) + socket_base_t (parent_, tid_, sid_), _pipe (NULL) { options.type = ZMQ_PAIR; } @@ -67,9 +38,6 @@ void zmq::pair_t::xattach_pipe (pipe_t *pipe_, void zmq::pair_t::xpipe_terminated (pipe_t *pipe_) { if (pipe_ == _pipe) { - if (_last_in == _pipe) { - _last_in = NULL; - } _pipe = NULL; } } @@ -117,7 +85,6 @@ int zmq::pair_t::xrecv (msg_t *msg_) errno = EAGAIN; return -1; } - _last_in = _pipe; return 0; } diff --git a/deps/zmq/src/pair.hpp b/deps/zmq/src/pair.hpp index 2d7bc071188..4c2a34a6154 100644 --- a/deps/zmq/src/pair.hpp +++ b/deps/zmq/src/pair.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PAIR_HPP_INCLUDED__ #define __ZMQ_PAIR_HPP_INCLUDED__ @@ -62,8 +35,6 @@ class pair_t ZMQ_FINAL : public socket_base_t private: zmq::pipe_t *_pipe; - zmq::pipe_t *_last_in; - ZMQ_NON_COPYABLE_NOR_MOVABLE (pair_t) }; } diff --git a/deps/zmq/src/peer.cpp b/deps/zmq/src/peer.cpp index 4d7e7461578..9d9c123ad4b 100644 --- a/deps/zmq/src/peer.cpp +++ b/deps/zmq/src/peer.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -42,6 +15,7 @@ zmq::peer_t::peer_t (class ctx_t *parent_, uint32_t tid_, int sid_) : options.type = ZMQ_PEER; options.can_send_hello_msg = true; options.can_recv_disconnect_msg = true; + options.can_recv_hiccup_msg = true; } uint32_t zmq::peer_t::connect_peer (const char *endpoint_uri_) diff --git a/deps/zmq/src/peer.hpp b/deps/zmq/src/peer.hpp index 96674b29ecf..5f62e3de11b 100644 --- a/deps/zmq/src/peer.hpp +++ b/deps/zmq/src/peer.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PEER_HPP_INCLUDED__ #define __ZMQ_PEER_HPP_INCLUDED__ diff --git a/deps/zmq/src/pgm_receiver.cpp b/deps/zmq/src/pgm_receiver.cpp index 227efa06392..a74d31f5cf4 100644 --- a/deps/zmq/src/pgm_receiver.cpp +++ b/deps/zmq/src/pgm_receiver.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" diff --git a/deps/zmq/src/pgm_receiver.hpp b/deps/zmq/src/pgm_receiver.hpp index cb033745357..0b8772d508d 100644 --- a/deps/zmq/src/pgm_receiver.hpp +++ b/deps/zmq/src/pgm_receiver.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PGM_RECEIVER_HPP_INCLUDED__ #define __ZMQ_PGM_RECEIVER_HPP_INCLUDED__ diff --git a/deps/zmq/src/pgm_sender.cpp b/deps/zmq/src/pgm_sender.cpp index 3c68f23b718..3a022030434 100644 --- a/deps/zmq/src/pgm_sender.cpp +++ b/deps/zmq/src/pgm_sender.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" @@ -96,7 +69,7 @@ void zmq::pgm_sender_t::plug (io_thread_t *io_thread_, session_base_t *session_) rdata_notify_handle = add_fd (rdata_notify_fd); pending_notify_handle = add_fd (pending_notify_fd); - // Set POLLIN. We wont never want to stop polling for uplink = we never + // Set POLLIN. We will never want to stop polling for uplink = we never // want to stop processing NAKs. set_pollin (uplink_handle); set_pollin (rdata_notify_handle); diff --git a/deps/zmq/src/pgm_sender.hpp b/deps/zmq/src/pgm_sender.hpp index 1d120c955d2..3b8643eac6a 100644 --- a/deps/zmq/src/pgm_sender.hpp +++ b/deps/zmq/src/pgm_sender.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PGM_SENDER_HPP_INCLUDED__ #define __ZMQ_PGM_SENDER_HPP_INCLUDED__ diff --git a/deps/zmq/src/pgm_socket.cpp b/deps/zmq/src/pgm_socket.cpp index e3399db1255..70d4d6f9f2d 100644 --- a/deps/zmq/src/pgm_socket.cpp +++ b/deps/zmq/src/pgm_socket.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" diff --git a/deps/zmq/src/pgm_socket.hpp b/deps/zmq/src/pgm_socket.hpp index 00ec4856e42..cbc7848f605 100644 --- a/deps/zmq/src/pgm_socket.hpp +++ b/deps/zmq/src/pgm_socket.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __PGM_SOCKET_HPP_INCLUDED__ #define __PGM_SOCKET_HPP_INCLUDED__ diff --git a/deps/zmq/src/pipe.cpp b/deps/zmq/src/pipe.cpp index b391b6eaef6..20caf5baca4 100644 --- a/deps/zmq/src/pipe.cpp +++ b/deps/zmq/src/pipe.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -597,7 +570,7 @@ void zmq::pipe_t::process_pipe_peer_stats (uint64_t queue_count_, void zmq::pipe_t::send_disconnect_msg () { - if (_disconnect_msg.size () > 0) { + if (_disconnect_msg.size () > 0 && _out_pipe) { // Rollback any incomplete message in the pipe, and push the disconnect message. rollback (); @@ -615,3 +588,15 @@ void zmq::pipe_t::set_disconnect_msg ( _disconnect_msg.init_buffer (&disconnect_[0], disconnect_.size ()); errno_assert (rc == 0); } + +void zmq::pipe_t::send_hiccup_msg (const std::vector &hiccup_) +{ + if (!hiccup_.empty () && _out_pipe) { + msg_t msg; + const int rc = msg.init_buffer (&hiccup_[0], hiccup_.size ()); + errno_assert (rc == 0); + + _out_pipe->write (msg, false); + flush (); + } +} diff --git a/deps/zmq/src/pipe.hpp b/deps/zmq/src/pipe.hpp index 8136b86007b..b5bc51e1e3d 100644 --- a/deps/zmq/src/pipe.hpp +++ b/deps/zmq/src/pipe.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PIPE_HPP_INCLUDED__ #define __ZMQ_PIPE_HPP_INCLUDED__ @@ -150,6 +123,8 @@ class pipe_t ZMQ_FINAL : public object_t, void send_disconnect_msg (); void set_disconnect_msg (const std::vector &disconnect_); + void send_hiccup_msg (const std::vector &hiccup_); + private: // Type of the underlying lock-free pipe. typedef ypipe_base_t upipe_t; diff --git a/deps/zmq/src/plain_client.cpp b/deps/zmq/src/plain_client.cpp index 2af6d1ddc0f..4c5d639e83d 100644 --- a/deps/zmq/src/plain_client.cpp +++ b/deps/zmq/src/plain_client.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -41,8 +14,7 @@ zmq::plain_client_t::plain_client_t (session_base_t *const session_, const options_t &options_) : - mechanism_base_t (session_, options_), - _state (sending_hello) + mechanism_base_t (session_, options_), _state (sending_hello) { } diff --git a/deps/zmq/src/plain_client.hpp b/deps/zmq/src/plain_client.hpp index 7b49d498cf0..45dc0f280be 100644 --- a/deps/zmq/src/plain_client.hpp +++ b/deps/zmq/src/plain_client.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PLAIN_CLIENT_HPP_INCLUDED__ #define __ZMQ_PLAIN_CLIENT_HPP_INCLUDED__ diff --git a/deps/zmq/src/plain_common.hpp b/deps/zmq/src/plain_common.hpp index c97e184eb30..80e43cc2477 100644 --- a/deps/zmq/src/plain_common.hpp +++ b/deps/zmq/src/plain_common.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PLAIN_COMMON_HPP_INCLUDED__ #define __ZMQ_PLAIN_COMMON_HPP_INCLUDED__ diff --git a/deps/zmq/src/plain_server.cpp b/deps/zmq/src/plain_server.cpp index 694c925e6d9..820a9dc4b07 100644 --- a/deps/zmq/src/plain_server.cpp +++ b/deps/zmq/src/plain_server.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" diff --git a/deps/zmq/src/plain_server.hpp b/deps/zmq/src/plain_server.hpp index 3e6e2d3f9ad..e3bf2d6d614 100644 --- a/deps/zmq/src/plain_server.hpp +++ b/deps/zmq/src/plain_server.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PLAIN_SERVER_HPP_INCLUDED__ #define __ZMQ_PLAIN_SERVER_HPP_INCLUDED__ diff --git a/deps/zmq/src/platform.hpp.in b/deps/zmq/src/platform.hpp.in index 445c41d81d0..ed77daa5c25 100644 --- a/deps/zmq/src/platform.hpp.in +++ b/deps/zmq/src/platform.hpp.in @@ -32,7 +32,7 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ERRNO_H -/* Define to 1 if you have the `fork' function. */ +/* fork is available */ #undef HAVE_FORK /* Define to 1 if you have the `freeifaddrs' function. */ @@ -92,9 +92,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET @@ -125,6 +122,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_STDIO_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H @@ -194,10 +194,13 @@ /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE -/* Define to 1 if you have the ANSI C header files. */ +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ #undef STDC_HEADERS -/* Define to 1 if you can safely include both and . */ +/* Define to 1 if you can safely include both and . This + macro is obsolete. */ #undef TIME_WITH_SYS_TIME /* Version number of package */ @@ -291,6 +294,9 @@ /* Whether O_CLOEXEC is defined and functioning. */ #undef ZMQ_HAVE_O_CLOEXEC +/* Build with zmq_ppoll */ +#undef ZMQ_HAVE_PPOLL + /* Whether pthread_setname_np() has 1 argument */ #undef ZMQ_HAVE_PTHREAD_SETNAME_1 @@ -381,6 +387,13 @@ /* Use 'select' I/O thread polling system */ #undef ZMQ_IOTHREAD_POLLER_USE_SELECT +/* Automatically close libsodium randombytes. Not threadsafe without + getrandom() */ +#undef ZMQ_LIBSODIUM_RANDOMBYTES_CLOSE + +/* kevent udata type is intptr_t */ +#undef ZMQ_NETBSD_KEVENT_UDATA_INTPTR_T + /* Use 'poll' zmq_poll(er)_* API polling system */ #undef ZMQ_POLL_BASED_ON_POLL @@ -417,9 +430,6 @@ /* Use radix tree implementation to manage subscriptions */ #undef ZMQ_USE_RADIX_TREE -/* Using tweetnacl for curve encryption */ -#undef ZMQ_USE_TWEETNACL - /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ diff --git a/deps/zmq/src/poll.cpp b/deps/zmq/src/poll.cpp index 67de088d43f..dd230ccfda7 100644 --- a/deps/zmq/src/poll.cpp +++ b/deps/zmq/src/poll.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "poll.hpp" @@ -42,8 +15,7 @@ #include "i_poll_events.hpp" zmq::poll_t::poll_t (const zmq::thread_ctx_t &ctx_) : - worker_poller_base_t (ctx_), - retired (false) + worker_poller_base_t (ctx_), retired (false) { } diff --git a/deps/zmq/src/poll.hpp b/deps/zmq/src/poll.hpp index 4c274425c85..01dede7d0dc 100644 --- a/deps/zmq/src/poll.hpp +++ b/deps/zmq/src/poll.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_POLL_HPP_INCLUDED__ #define __ZMQ_POLL_HPP_INCLUDED__ diff --git a/deps/zmq/src/poller.hpp b/deps/zmq/src/poller.hpp index ba9fbb173bb..192fc5021fc 100644 --- a/deps/zmq/src/poller.hpp +++ b/deps/zmq/src/poller.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_POLLER_HPP_INCLUDED__ #define __ZMQ_POLLER_HPP_INCLUDED__ diff --git a/deps/zmq/src/poller_base.cpp b/deps/zmq/src/poller_base.cpp index 78db28f6582..dd8453b322d 100644 --- a/deps/zmq/src/poller_base.cpp +++ b/deps/zmq/src/poller_base.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "poller_base.hpp" diff --git a/deps/zmq/src/poller_base.hpp b/deps/zmq/src/poller_base.hpp index b39f2a4120d..4182526147f 100644 --- a/deps/zmq/src/poller_base.hpp +++ b/deps/zmq/src/poller_base.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_POLLER_BASE_HPP_INCLUDED__ #define __ZMQ_POLLER_BASE_HPP_INCLUDED__ diff --git a/deps/zmq/src/polling_util.cpp b/deps/zmq/src/polling_util.cpp index c8e42eb8d53..7564297bb3c 100644 --- a/deps/zmq/src/polling_util.cpp +++ b/deps/zmq/src/polling_util.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2018 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "polling_util.hpp" diff --git a/deps/zmq/src/polling_util.hpp b/deps/zmq/src/polling_util.hpp index 2af8c4561b6..13a4911ffbd 100644 --- a/deps/zmq/src/polling_util.hpp +++ b/deps/zmq/src/polling_util.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2018 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_SOCKET_POLLING_UTIL_HPP_INCLUDED__ #define __ZMQ_SOCKET_POLLING_UTIL_HPP_INCLUDED__ @@ -33,6 +6,12 @@ #include #include +#if defined ZMQ_HAVE_WINDOWS +#include +#else +#include +#endif + #include "macros.hpp" #include "stdint.hpp" #include "platform.hpp" @@ -46,7 +25,7 @@ template class fast_vector_t explicit fast_vector_t (const size_t nitems_) { if (nitems_ > S) { - _buf = static_cast (malloc (nitems_ * sizeof (T))); + _buf = new (std::nothrow) T[nitems_]; // TODO since this function is called by a client, we could return errno == ENOMEM here alloc_assert (_buf); } else { @@ -59,7 +38,7 @@ template class fast_vector_t ~fast_vector_t () { if (_buf != _static_buf) - free (_buf); + delete[] _buf; } private: @@ -76,12 +55,13 @@ template class resizable_fast_vector_t void resize (const size_t nitems_) { - if (_dynamic_buf) + if (_dynamic_buf) { _dynamic_buf->resize (nitems_); - if (nitems_ > S) { - _dynamic_buf = new (std::nothrow) std::vector; + } else if (nitems_ > S) { + _dynamic_buf = new (std::nothrow) std::vector (nitems_); // TODO since this function is called by a client, we could return errno == ENOMEM here alloc_assert (_dynamic_buf); + memcpy (&(*_dynamic_buf)[0], _static_buf, sizeof _static_buf); } } @@ -107,11 +87,12 @@ typedef int timeout_t; timeout_t compute_timeout (bool first_pass_, long timeout_, uint64_t now_, uint64_t end_); - -#elif defined ZMQ_POLL_BASED_ON_SELECT +#endif +#if (!defined ZMQ_POLL_BASED_ON_POLL && defined ZMQ_POLL_BASED_ON_SELECT) \ + || defined ZMQ_HAVE_PPOLL +#if defined ZMQ_HAVE_WINDOWS inline size_t valid_pollset_bytes (const fd_set &pollset_) { -#if defined ZMQ_HAVE_WINDOWS // On Windows we don't need to copy the whole fd_set. // SOCKETS are continuous from the beginning of fd_array in fd_set. // We just need to copy fd_count elements of fd_array. @@ -119,10 +100,14 @@ inline size_t valid_pollset_bytes (const fd_set &pollset_) return reinterpret_cast ( &pollset_.fd_array[pollset_.fd_count]) - reinterpret_cast (&pollset_); +} #else +inline size_t valid_pollset_bytes (const fd_set & /*pollset_*/) +{ return sizeof (fd_set); -#endif } +#endif + #if defined ZMQ_HAVE_WINDOWS // struct fd_set { diff --git a/deps/zmq/src/pollset.cpp b/deps/zmq/src/pollset.cpp index 1a1dee954be..3554276b99b 100644 --- a/deps/zmq/src/pollset.cpp +++ b/deps/zmq/src/pollset.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "pollset.hpp" @@ -43,8 +16,7 @@ #include "i_poll_events.hpp" zmq::pollset_t::pollset_t (const zmq::thread_ctx_t &ctx_) : - ctx (ctx_), - stopping (false) + ctx (ctx_), stopping (false) { pollset_fd = pollset_create (-1); errno_assert (pollset_fd != -1); diff --git a/deps/zmq/src/pollset.hpp b/deps/zmq/src/pollset.hpp index 8286bed296b..8030764c61e 100644 --- a/deps/zmq/src/pollset.hpp +++ b/deps/zmq/src/pollset.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_POLLSET_HPP_INCLUDED__ #define __ZMQ_POLLSET_HPP_INCLUDED__ diff --git a/deps/zmq/src/precompiled.cpp b/deps/zmq/src/precompiled.cpp index acf58f76f77..af41625f039 100644 --- a/deps/zmq/src/precompiled.cpp +++ b/deps/zmq/src/precompiled.cpp @@ -1,30 +1,3 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" diff --git a/deps/zmq/src/precompiled.hpp b/deps/zmq/src/precompiled.hpp index f22a693745d..0bc7fe6d724 100644 --- a/deps/zmq/src/precompiled.hpp +++ b/deps/zmq/src/precompiled.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PRECOMPILED_HPP_INCLUDED__ #define __ZMQ_PRECOMPILED_HPP_INCLUDED__ @@ -70,7 +43,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/deps/zmq/src/proxy.cpp b/deps/zmq/src/proxy.cpp index 8a517c7829c..78d6ba6178d 100644 --- a/deps/zmq/src/proxy.cpp +++ b/deps/zmq/src/proxy.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" @@ -45,6 +18,13 @@ #include "socket_base.hpp" #include "err.hpp" +int zmq::proxy (class socket_base_t *frontend_, + class socket_base_t *backend_, + class socket_base_t *capture_) +{ + return zmq::proxy_steerable (frontend_, backend_, capture_, NULL); +} + #ifdef ZMQ_HAVE_POLLER #include "socket_poller.hpp" @@ -56,7 +36,6 @@ do { \ delete poller_all; \ delete poller_in; \ - delete poller_control; \ delete poller_receive_blocked; \ delete poller_send_blocked; \ delete poller_both_blocked; \ @@ -75,20 +54,6 @@ #endif // ZMQ_HAVE_POLLER - -// Control socket messages - -typedef struct -{ - uint64_t msg_in; - uint64_t bytes_in; - uint64_t msg_out; - uint64_t bytes_out; -} zmq_socket_stats_t; - - -// Utility functions - static int capture (class zmq::socket_base_t *capture_, zmq::msg_t *msg_, int more_ = 0) { @@ -108,18 +73,30 @@ capture (class zmq::socket_base_t *capture_, zmq::msg_t *msg_, int more_ = 0) return 0; } +struct stats_socket +{ + uint64_t count, bytes; +}; +struct stats_endpoint +{ + stats_socket send, recv; +}; +struct stats_proxy +{ + stats_endpoint frontend, backend; +}; + static int forward (class zmq::socket_base_t *from_, - zmq_socket_stats_t *from_stats_, class zmq::socket_base_t *to_, - zmq_socket_stats_t *to_stats_, class zmq::socket_base_t *capture_, - zmq::msg_t *msg_) + zmq::msg_t *msg_, + stats_socket &recving, + stats_socket &sending) { // Forward a burst of messages for (unsigned int i = 0; i < zmq::proxy_burst_size; i++) { int more; size_t moresz; - size_t complete_msg_size = 0; // Forward all the parts of one message while (true) { @@ -131,7 +108,9 @@ static int forward (class zmq::socket_base_t *from_, return -1; } - complete_msg_size += msg_->size (); + size_t nbytes = msg_->size (); + recving.count += 1; + recving.bytes += nbytes; moresz = sizeof more; rc = from_->getsockopt (ZMQ_RCVMORE, &more, &moresz); @@ -146,80 +125,92 @@ static int forward (class zmq::socket_base_t *from_, rc = to_->send (msg_, more ? ZMQ_SNDMORE : 0); if (unlikely (rc < 0)) return -1; + sending.count += 1; + sending.bytes += nbytes; if (more == 0) break; } - - // A multipart message counts as 1 packet: - from_stats_->msg_in++; - from_stats_->bytes_in += complete_msg_size; - to_stats_->msg_out++; - to_stats_->bytes_out += complete_msg_size; } return 0; } -static int loop_and_send_multipart_stat (zmq::socket_base_t *control_, - uint64_t stat_, - bool first_, - bool more_) +enum proxy_state_t { - int rc; - zmq::msg_t msg; - - // VSM of 8 bytes can't fail to init - msg.init_size (sizeof (uint64_t)); - memcpy (msg.data (), &stat_, sizeof (uint64_t)); - - // if the first message is handed to the pipe successfully then the HWM - // is not full, which means failures are due to interrupts (on Windows pipes - // are TCP sockets), so keep retrying - do { - rc = control_->send (&msg, more_ ? ZMQ_SNDMORE : 0); - } while (!first_ && rc != 0 && errno == EAGAIN); - - return rc; -} - -static int reply_stats (zmq::socket_base_t *control_, - const zmq_socket_stats_t *frontend_stats_, - const zmq_socket_stats_t *backend_stats_) + active, + paused, + terminated +}; + +// Handle control request [5]PAUSE, [6]RESUME, [9]TERMINATE, +// [10]STATISTICS. Only STATISTICS results in a send. +static int handle_control (class zmq::socket_base_t *control_, + proxy_state_t &state, + const stats_proxy &stats) { - // first part: frontend stats - the first send might fail due to HWM - if (loop_and_send_multipart_stat (control_, frontend_stats_->msg_in, true, - true) - != 0) + zmq::msg_t cmsg; + int rc = cmsg.init (); + if (rc != 0) { return -1; + } + rc = control_->recv (&cmsg, ZMQ_DONTWAIT); + if (rc < 0) { + return -1; + } + uint8_t *const command = static_cast (cmsg.data ()); + const size_t msiz = cmsg.size (); + + if (msiz == 10 && 0 == memcmp (command, "STATISTICS", 10)) { + // The stats are a cross product: + // + // (Front,Back) X (Recv,Sent) X (Number,Bytes). + // + // that is flattened into sequence of 8 message parts according to the + // zmq_proxy_steerable(3) documentation as: + // + // (frn, frb, fsn, fsb, brn, brb, bsn, bsb) + // + // f=front/b=back, r=recv/s=send, n=number/b=bytes. + const uint64_t stat_vals[8] = { + stats.frontend.recv.count, stats.frontend.recv.bytes, + stats.frontend.send.count, stats.frontend.send.bytes, + stats.backend.recv.count, stats.backend.recv.bytes, + stats.backend.send.count, stats.backend.send.bytes}; + + for (size_t ind = 0; ind < 8; ++ind) { + cmsg.init_size (sizeof (uint64_t)); + memcpy (cmsg.data (), stat_vals + ind, sizeof (uint64_t)); + rc = control_->send (&cmsg, ind < 7 ? ZMQ_SNDMORE : 0); + if (unlikely (rc < 0)) { + return -1; + } + } + return 0; + } - loop_and_send_multipart_stat (control_, frontend_stats_->bytes_in, false, - true); - loop_and_send_multipart_stat (control_, frontend_stats_->msg_out, false, - true); - loop_and_send_multipart_stat (control_, frontend_stats_->bytes_out, false, - true); - - // second part: backend stats - loop_and_send_multipart_stat (control_, backend_stats_->msg_in, false, - true); - loop_and_send_multipart_stat (control_, backend_stats_->bytes_in, false, - true); - loop_and_send_multipart_stat (control_, backend_stats_->msg_out, false, - true); - loop_and_send_multipart_stat (control_, backend_stats_->bytes_out, false, - false); + if (msiz == 5 && memcmp (command, "\x05PAUSE", 6)) { + state = active; + } else if (msiz == 6 && 0 == memcmp (command, "RESUME", 6)) { + state = paused; + } else if (msiz == 9 && 0 == memcmp (command, "TERMINATE", 9)) { + state = terminated; + } + // satisfy REP duty and reply no matter what. + cmsg.init_size (0); + rc = control_->send (&cmsg, 0); + if (unlikely (rc < 0)) { + return -1; + } return 0; } - #ifdef ZMQ_HAVE_POLLER - -int zmq::proxy (class socket_base_t *frontend_, - class socket_base_t *backend_, - class socket_base_t *capture_, - class socket_base_t *control_) +int zmq::proxy_steerable (class socket_base_t *frontend_, + class socket_base_t *backend_, + class socket_base_t *capture_, + class socket_base_t *control_) { msg_t msg; int rc = msg.init (); @@ -229,28 +220,18 @@ int zmq::proxy (class socket_base_t *frontend_, // The algorithm below assumes ratio of requests and replies processed // under full load to be 1:1. - int more; - size_t moresz = sizeof (more); - // Proxy can be in these three states - enum - { - active, - paused, - terminated - } state = active; + proxy_state_t state = active; bool frontend_equal_to_backend; bool frontend_in = false; bool frontend_out = false; bool backend_in = false; bool backend_out = false; - bool control_in = false; - zmq::socket_poller_t::event_t events[3]; - zmq_socket_stats_t frontend_stats; - zmq_socket_stats_t backend_stats; - memset (&frontend_stats, 0, sizeof (frontend_stats)); - memset (&backend_stats, 0, sizeof (backend_stats)); + zmq::socket_poller_t::event_t events[4]; + int nevents = 3; // increase to 4 if we have control_ + + stats_proxy stats = {{{0, 0}, {0, 0}}, {{0, 0}, {0, 0}}}; // Don't allocate these pollers from stack because they will take more than 900 kB of stack! // On Windows this blows up default stack of 1 MB and aborts the program. @@ -259,8 +240,6 @@ int zmq::proxy (class socket_base_t *frontend_, new (std::nothrow) zmq::socket_poller_t; // Poll for everything. zmq::socket_poller_t *poller_in = new (std::nothrow) zmq:: socket_poller_t; // Poll only 'ZMQ_POLLIN' on all sockets. Initial blocking poll in loop. - zmq::socket_poller_t *poller_control = new (std::nothrow) zmq:: - socket_poller_t; // Poll only for 'ZMQ_POLLIN' on 'control_', when proxy is paused. zmq::socket_poller_t *poller_receive_blocked = new (std::nothrow) zmq::socket_poller_t; // All except 'ZMQ_POLLIN' on 'frontend_'. @@ -290,7 +269,7 @@ int zmq::proxy (class socket_base_t *frontend_, } else frontend_equal_to_backend = true; - if (poller_all == NULL || poller_in == NULL || poller_control == NULL + if (poller_all == NULL || poller_in == NULL || poller_receive_blocked == NULL || ((poller_send_blocked == NULL || poller_both_blocked == NULL) && !frontend_equal_to_backend)) { @@ -350,110 +329,76 @@ int zmq::proxy (class socket_base_t *frontend_, CHECK_RC_EXIT_ON_FAILURE (); } - // Register 'control_' with pollers. - if (control_ != NULL) { + if (control_) { + ++nevents; + + // wherever you go, there you are. + rc = poller_all->add (control_, NULL, ZMQ_POLLIN); CHECK_RC_EXIT_ON_FAILURE (); + rc = poller_in->add (control_, NULL, ZMQ_POLLIN); CHECK_RC_EXIT_ON_FAILURE (); - rc = poller_control->add ( - control_, NULL, - ZMQ_POLLIN); // When proxy is paused we wait only for ZMQ_POLLIN on 'control_' socket. - CHECK_RC_EXIT_ON_FAILURE (); + rc = poller_receive_blocked->add (control_, NULL, ZMQ_POLLIN); CHECK_RC_EXIT_ON_FAILURE (); - if (!frontend_equal_to_backend) { - rc = poller_send_blocked->add (control_, NULL, ZMQ_POLLIN); - CHECK_RC_EXIT_ON_FAILURE (); - rc = poller_both_blocked->add (control_, NULL, ZMQ_POLLIN); - CHECK_RC_EXIT_ON_FAILURE (); - rc = poller_frontend_only->add (control_, NULL, ZMQ_POLLIN); - CHECK_RC_EXIT_ON_FAILURE (); - rc = poller_backend_only->add (control_, NULL, ZMQ_POLLIN); - CHECK_RC_EXIT_ON_FAILURE (); - } + + rc = poller_send_blocked->add (control_, NULL, ZMQ_POLLIN); + CHECK_RC_EXIT_ON_FAILURE (); + + rc = poller_both_blocked->add (control_, NULL, ZMQ_POLLIN); + CHECK_RC_EXIT_ON_FAILURE (); + + rc = poller_frontend_only->add (control_, NULL, ZMQ_POLLIN); + CHECK_RC_EXIT_ON_FAILURE (); + + rc = poller_backend_only->add (control_, NULL, ZMQ_POLLIN); + CHECK_RC_EXIT_ON_FAILURE (); } - bool request_processed, reply_processed; + bool request_processed = false, reply_processed = false; while (state != terminated) { // Blocking wait initially only for 'ZMQ_POLLIN' - 'poller_wait' points to 'poller_in'. // If one of receiving end's queue is full ('ZMQ_POLLOUT' not available), // 'poller_wait' is pointed to 'poller_receive_blocked', 'poller_send_blocked' or 'poller_both_blocked'. - rc = poller_wait->wait (events, 3, -1); + rc = poller_wait->wait (events, nevents, -1); if (rc < 0 && errno == EAGAIN) rc = 0; CHECK_RC_EXIT_ON_FAILURE (); // Some of events waited for by 'poller_wait' have arrived, now poll for everything without blocking. - rc = poller_all->wait (events, 3, 0); + rc = poller_all->wait (events, nevents, 0); if (rc < 0 && errno == EAGAIN) rc = 0; CHECK_RC_EXIT_ON_FAILURE (); // Process events. for (int i = 0; i < rc; i++) { + if (control_ && events[i].socket == control_) { + rc = handle_control (control_, state, stats); + CHECK_RC_EXIT_ON_FAILURE (); + continue; + } + if (events[i].socket == frontend_) { frontend_in = (events[i].events & ZMQ_POLLIN) != 0; frontend_out = (events[i].events & ZMQ_POLLOUT) != 0; } else - // This 'if' needs to be after check for 'frontend_' in order never - // to be reached in case frontend_==backend_, so we ensure backend_in=false in that case. - if (events[i].socket == backend_) { - backend_in = (events[i].events & ZMQ_POLLIN) != 0; - backend_out = (events[i].events & ZMQ_POLLOUT) != 0; - } else if (events[i].socket == control_) - control_in = (events[i].events & ZMQ_POLLIN) != 0; - } - - - // Process a control command if any. - if (control_in) { - rc = control_->recv (&msg, 0); - CHECK_RC_EXIT_ON_FAILURE (); - rc = control_->getsockopt (ZMQ_RCVMORE, &more, &moresz); - if (unlikely (rc < 0) || more) { - PROXY_CLEANUP (); - return close_and_return (&msg, -1); - } - - // Copy message to capture socket if any. - rc = capture (capture_, &msg); - CHECK_RC_EXIT_ON_FAILURE (); - - if (msg.size () == 5 && memcmp (msg.data (), "PAUSE", 5) == 0) { - state = paused; - poller_wait = poller_control; - } else if (msg.size () == 6 - && memcmp (msg.data (), "RESUME", 6) == 0) { - state = active; - poller_wait = poller_in; - } else { - if (msg.size () == 9 - && memcmp (msg.data (), "TERMINATE", 9) == 0) - state = terminated; - else { - if (msg.size () == 10 - && memcmp (msg.data (), "STATISTICS", 10) == 0) { - rc = reply_stats (control_, &frontend_stats, - &backend_stats); - CHECK_RC_EXIT_ON_FAILURE (); - } else { - // This is an API error, we assert - puts ("E: invalid command sent to proxy"); - zmq_assert (false); - } + // This 'if' needs to be after check for 'frontend_' in order never + // to be reached in case frontend_==backend_, so we ensure backend_in=false in that case. + if (events[i].socket == backend_) { + backend_in = (events[i].events & ZMQ_POLLIN) != 0; + backend_out = (events[i].events & ZMQ_POLLOUT) != 0; } - } - control_in = false; } if (state == active) { // Process a request, 'ZMQ_POLLIN' on 'frontend_' and 'ZMQ_POLLOUT' on 'backend_'. // In case of frontend_==backend_ there's no 'ZMQ_POLLOUT' event. if (frontend_in && (backend_out || frontend_equal_to_backend)) { - rc = forward (frontend_, &frontend_stats, backend_, - &backend_stats, capture_, &msg); + rc = forward (frontend_, backend_, capture_, &msg, + stats.frontend.recv, stats.backend.send); CHECK_RC_EXIT_ON_FAILURE (); request_processed = true; frontend_in = backend_out = false; @@ -465,8 +410,8 @@ int zmq::proxy (class socket_base_t *frontend_, // covers all of the cases. 'backend_in' is always false if frontend_==backend_ due to // design in 'for' event processing loop. if (backend_in && frontend_out) { - rc = forward (backend_, &backend_stats, frontend_, - &frontend_stats, capture_, &msg); + rc = forward (backend_, frontend_, capture_, &msg, + stats.backend.recv, stats.frontend.send); CHECK_RC_EXIT_ON_FAILURE (); reply_processed = true; backend_in = frontend_out = false; @@ -533,10 +478,10 @@ int zmq::proxy (class socket_base_t *frontend_, #else // ZMQ_HAVE_POLLER -int zmq::proxy (class socket_base_t *frontend_, - class socket_base_t *backend_, - class socket_base_t *capture_, - class socket_base_t *control_) +int zmq::proxy_steerable (class socket_base_t *frontend_, + class socket_base_t *backend_, + class socket_base_t *capture_, + class socket_base_t *control_) { msg_t msg; int rc = msg.init (); @@ -546,27 +491,18 @@ int zmq::proxy (class socket_base_t *frontend_, // The algorithm below assumes ratio of requests and replies processed // under full load to be 1:1. - int more; - size_t moresz; zmq_pollitem_t items[] = {{frontend_, 0, ZMQ_POLLIN, 0}, {backend_, 0, ZMQ_POLLIN, 0}, {control_, 0, ZMQ_POLLIN, 0}}; - int qt_poll_items = (control_ ? 3 : 2); + const int qt_poll_items = control_ ? 3 : 2; + zmq_pollitem_t itemsout[] = {{frontend_, 0, ZMQ_POLLOUT, 0}, {backend_, 0, ZMQ_POLLOUT, 0}}; - zmq_socket_stats_t frontend_stats; - memset (&frontend_stats, 0, sizeof (frontend_stats)); - zmq_socket_stats_t backend_stats; - memset (&backend_stats, 0, sizeof (backend_stats)); + stats_proxy stats = {0}; // Proxy can be in these three states - enum - { - active, - paused, - terminated - } state = active; + proxy_state_t state = active; while (state != terminated) { // Wait while there are either requests or replies to process. @@ -574,6 +510,12 @@ int zmq::proxy (class socket_base_t *frontend_, if (unlikely (rc < 0)) return close_and_return (&msg, -1); + if (control_ && items[2].revents & ZMQ_POLLIN) { + rc = handle_control (control_, state, stats); + if (unlikely (rc < 0)) + return close_and_return (&msg, -1); + } + // Get the pollout separately because when combining this with pollin it maxes the CPU // because pollout shall most of the time return directly. // POLLOUT is only checked when frontend and backend sockets are not the same. @@ -584,48 +526,10 @@ int zmq::proxy (class socket_base_t *frontend_, } } - // Process a control command if any - if (control_ && items[2].revents & ZMQ_POLLIN) { - rc = control_->recv (&msg, 0); - if (unlikely (rc < 0)) - return close_and_return (&msg, -1); - - moresz = sizeof more; - rc = control_->getsockopt (ZMQ_RCVMORE, &more, &moresz); - if (unlikely (rc < 0) || more) - return close_and_return (&msg, -1); - - // Copy message to capture socket if any - rc = capture (capture_, &msg); - if (unlikely (rc < 0)) - return close_and_return (&msg, -1); - - if (msg.size () == 5 && memcmp (msg.data (), "PAUSE", 5) == 0) - state = paused; - else if (msg.size () == 6 && memcmp (msg.data (), "RESUME", 6) == 0) - state = active; - else if (msg.size () == 9 - && memcmp (msg.data (), "TERMINATE", 9) == 0) - state = terminated; - else { - if (msg.size () == 10 - && memcmp (msg.data (), "STATISTICS", 10) == 0) { - rc = - reply_stats (control_, &frontend_stats, &backend_stats); - if (unlikely (rc < 0)) - return close_and_return (&msg, -1); - } else { - // This is an API error, we assert - puts ("E: invalid command sent to proxy"); - zmq_assert (false); - } - } - } - // Process a request if (state == active && items[0].revents & ZMQ_POLLIN && (frontend_ == backend_ || itemsout[1].revents & ZMQ_POLLOUT)) { - rc = forward (frontend_, &frontend_stats, backend_, &backend_stats, - capture_, &msg); + rc = forward (frontend_, backend_, capture_, &msg, + stats.frontend.recv, stats.backend.send); if (unlikely (rc < 0)) return close_and_return (&msg, -1); } @@ -633,8 +537,8 @@ int zmq::proxy (class socket_base_t *frontend_, if (state == active && frontend_ != backend_ && items[1].revents & ZMQ_POLLIN && itemsout[0].revents & ZMQ_POLLOUT) { - rc = forward (backend_, &backend_stats, frontend_, &frontend_stats, - capture_, &msg); + rc = forward (backend_, frontend_, capture_, &msg, + stats.backend.recv, stats.frontend.send); if (unlikely (rc < 0)) return close_and_return (&msg, -1); } diff --git a/deps/zmq/src/proxy.hpp b/deps/zmq/src/proxy.hpp index f078c6ae59c..e684e97db17 100644 --- a/deps/zmq/src/proxy.hpp +++ b/deps/zmq/src/proxy.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PROXY_HPP_INCLUDED__ #define __ZMQ_PROXY_HPP_INCLUDED__ @@ -34,9 +7,12 @@ namespace zmq { int proxy (class socket_base_t *frontend_, class socket_base_t *backend_, - class socket_base_t *capture_, - class socket_base_t *control_ = - NULL); // backward compatibility without this argument + class socket_base_t *capture_); + +int proxy_steerable (class socket_base_t *frontend_, + class socket_base_t *backend_, + class socket_base_t *capture_, + class socket_base_t *control_); } #endif diff --git a/deps/zmq/src/pub.cpp b/deps/zmq/src/pub.cpp index fe42982ed7e..49a91a6ce62 100644 --- a/deps/zmq/src/pub.cpp +++ b/deps/zmq/src/pub.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "pub.hpp" diff --git a/deps/zmq/src/pub.hpp b/deps/zmq/src/pub.hpp index b423da02669..3b7f0e42764 100644 --- a/deps/zmq/src/pub.hpp +++ b/deps/zmq/src/pub.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PUB_HPP_INCLUDED__ #define __ZMQ_PUB_HPP_INCLUDED__ diff --git a/deps/zmq/src/pull.cpp b/deps/zmq/src/pull.cpp index 9c9a843e339..927f941a876 100644 --- a/deps/zmq/src/pull.cpp +++ b/deps/zmq/src/pull.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" diff --git a/deps/zmq/src/pull.hpp b/deps/zmq/src/pull.hpp index 4634d82c430..42d4590907b 100644 --- a/deps/zmq/src/pull.hpp +++ b/deps/zmq/src/pull.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PULL_HPP_INCLUDED__ #define __ZMQ_PULL_HPP_INCLUDED__ diff --git a/deps/zmq/src/push.cpp b/deps/zmq/src/push.cpp index 42184807ce4..2a357f7c675 100644 --- a/deps/zmq/src/push.cpp +++ b/deps/zmq/src/push.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" diff --git a/deps/zmq/src/push.hpp b/deps/zmq/src/push.hpp index 3b908c1095a..05627d24c96 100644 --- a/deps/zmq/src/push.hpp +++ b/deps/zmq/src/push.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_PUSH_HPP_INCLUDED__ #define __ZMQ_PUSH_HPP_INCLUDED__ diff --git a/deps/zmq/src/radio.cpp b/deps/zmq/src/radio.cpp index aa9f100af89..60799437008 100644 --- a/deps/zmq/src/radio.cpp +++ b/deps/zmq/src/radio.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -37,8 +10,7 @@ #include "msg.hpp" zmq::radio_t::radio_t (class ctx_t *parent_, uint32_t tid_, int sid_) : - socket_base_t (parent_, tid_, sid_, true), - _lossy (true) + socket_base_t (parent_, tid_, sid_, true), _lossy (true) { options.type = ZMQ_RADIO; } diff --git a/deps/zmq/src/radio.hpp b/deps/zmq/src/radio.hpp index 8b3bd64123d..9a59e2d3bf0 100644 --- a/deps/zmq/src/radio.hpp +++ b/deps/zmq/src/radio.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_RADIO_HPP_INCLUDED__ #define __ZMQ_RADIO_HPP_INCLUDED__ diff --git a/deps/zmq/src/radix_tree.cpp b/deps/zmq/src/radix_tree.cpp index 04374eec510..1bbc2423344 100644 --- a/deps/zmq/src/radix_tree.cpp +++ b/deps/zmq/src/radix_tree.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2018 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -326,7 +299,7 @@ bool zmq::radix_tree_t::add (const unsigned char *key_, size_t key_size_) _root._data = current_node._data; else parent_node.set_node_at (edge_index, current_node); - ++_size; + _size.add (1); return true; } @@ -362,7 +335,7 @@ bool zmq::radix_tree_t::add (const unsigned char *key_, size_t key_size_) current_node.set_edge_at (0, key_node.prefix ()[0], key_node); current_node.set_edge_at (1, split_node.prefix ()[0], split_node); - ++_size; + _size.add (1); parent_node.set_node_at (edge_index, current_node); return true; } @@ -394,7 +367,7 @@ bool zmq::radix_tree_t::add (const unsigned char *key_, size_t key_size_) current_node.set_edge_at (0, split_node.prefix ()[0], split_node); current_node.set_refcount (1); - ++_size; + _size.add (1); parent_node.set_node_at (edge_index, current_node); return true; } @@ -402,7 +375,7 @@ bool zmq::radix_tree_t::add (const unsigned char *key_, size_t key_size_) zmq_assert (key_bytes_matched == key_size_); zmq_assert (prefix_bytes_matched == current_node.prefix_length ()); - ++_size; + _size.add (1); current_node.set_refcount (current_node.refcount () + 1); return current_node.refcount () == 1; } @@ -424,7 +397,7 @@ bool zmq::radix_tree_t::rm (const unsigned char *key_, size_t key_size_) return false; current_node.set_refcount (current_node.refcount () - 1); - --_size; + _size.sub (1); if (current_node.refcount () > 0) return false; @@ -558,7 +531,7 @@ visit_keys (node_t node_, for (size_t i = 0, edgecount = node_.edgecount (); i < edgecount; ++i) { visit_keys (node_.node_at (i), buffer_, func_, arg_); } - buffer_.resize (buffer_.size () - prefix_length); + buffer_.resize (static_cast (buffer_.size () - prefix_length)); } void zmq::radix_tree_t::apply ( @@ -574,5 +547,5 @@ void zmq::radix_tree_t::apply ( size_t zmq::radix_tree_t::size () const { - return _size; + return _size.get (); } diff --git a/deps/zmq/src/radix_tree.hpp b/deps/zmq/src/radix_tree.hpp index 02e74969c84..13e358ccf3b 100644 --- a/deps/zmq/src/radix_tree.hpp +++ b/deps/zmq/src/radix_tree.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2018 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef RADIX_TREE_HPP #define RADIX_TREE_HPP @@ -33,6 +6,7 @@ #include #include "stdint.hpp" +#include "atomic_counter.hpp" // Wrapper type for a node's data layout. // @@ -133,6 +107,7 @@ class radix_tree_t void apply (void (*func_) (unsigned char *data, size_t size, void *arg), void *arg_); + // Retrieve size of the radix tree. Note this is a multithread safe function. size_t size () const; private: @@ -140,7 +115,7 @@ class radix_tree_t match (const unsigned char *key_, size_t key_size_, bool is_lookup_) const; node_t _root; - size_t _size; + atomic_counter_t _size; }; } diff --git a/deps/zmq/src/random.cpp b/deps/zmq/src/random.cpp index 17c3537df32..070229100fa 100644 --- a/deps/zmq/src/random.cpp +++ b/deps/zmq/src/random.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2017 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -40,9 +13,7 @@ #include "mutex.hpp" #include "macros.hpp" -#if defined(ZMQ_USE_TWEETNACL) -#include "tweetnacl.h" -#elif defined(ZMQ_USE_LIBSODIUM) +#if defined(ZMQ_USE_LIBSODIUM) #include "sodium.h" #endif @@ -65,94 +36,20 @@ uint32_t zmq::generate_random () return high | low; } -// When different threads have their own context the file descriptor -// variable is shared and is subject to race conditions in tweetnacl, -// that lead to file descriptors leaks. In long-running programs with -// ephemeral threads this is a problem as it accumulates. -// thread-local storage cannot be used to initialise the file descriptor -// as it is perfectly legal to share a context among many threads, each -// of which might call curve APIs. -// Also libsodium documentation specifically states that sodium_init -// must not be called concurrently from multiple threads, for the -// same reason. Inspecting the code also reveals that the close API is -// not thread safe. -// The context class cannot be used with static variables as the curve -// utility APIs like zmq_curve_keypair also call into the crypto -// library. -// The safest solution for all use cases therefore is to have a -// static lock to serialize calls into an initialiser and a finaliser, -// using refcounts to make sure that a thread does not close the library -// while another is still using it. To avoid the static initialization -// order fiasco, this is done using function-local statics, if the -// compiler implementation supports thread-safe initialization of those. -// Otherwise, we fall back to global statics. -// HOWEVER, this initialisation code imposes ordering constraints, which -// are not obvious to users of libzmq, and may lead to problems if atexit -// or similar methods are used for cleanup. -// In that case, a strict ordering is imposed whereas the contexts MUST -// be initialised BEFORE registering the cleanup with atexit. CZMQ is an -// example. Hence we make the choice to restrict this global transition -// mechanism ONLY to Tweenacl + *NIX (when using /dev/urandom) as it is -// the less risky option. - -// TODO if there is some other user of libsodium besides libzmq, this must -// be synchronized by the application. This should probably also be -// configurable via config.h - -// TODO this should probably be done via config.h -#if __cplusplus >= 201103L \ - || (defined(__cpp_threadsafe_static_init) \ - && __cpp_threadsafe_static_init >= 200806) \ - || (defined(_MSC_VER) && _MSC_VER >= 1900) -#define ZMQ_HAVE_THREADSAFE_STATIC_LOCAL_INIT 1 -// TODO this might probably also be set if a sufficiently recent gcc is used -// without -fno-threadsafe-statics, but this cannot be determined at -// compile-time, so it must be set via config.h -#else -#define ZMQ_HAVE_THREADSAFE_STATIC_LOCAL_INIT 0 -#endif - -#if !ZMQ_HAVE_THREADSAFE_STATIC_LOCAL_INIT \ - && (defined(ZMQ_USE_TWEETNACL) && !defined(ZMQ_HAVE_WINDOWS) \ - && !defined(ZMQ_HAVE_GETRANDOM)) -static unsigned int random_refcount = 0; -static zmq::mutex_t random_sync; -#endif - static void manage_random (bool init_) { -#if defined(ZMQ_USE_TWEETNACL) && !defined(ZMQ_HAVE_WINDOWS) \ - && !defined(ZMQ_HAVE_GETRANDOM) - -#if ZMQ_HAVE_THREADSAFE_STATIC_LOCAL_INIT - static int random_refcount = 0; - static zmq::mutex_t random_sync; -#endif - - if (init_) { - zmq::scoped_lock_t locker (random_sync); - - if (random_refcount == 0) { - int rc = sodium_init (); - zmq_assert (rc != -1); - } - - ++random_refcount; - } else { - zmq::scoped_lock_t locker (random_sync); - --random_refcount; - - if (random_refcount == 0) { - randombytes_close (); - } - } - -#elif defined(ZMQ_USE_LIBSODIUM) +#if defined(ZMQ_USE_LIBSODIUM) if (init_) { + // sodium_init() is now documented as thread-safe in recent versions int rc = sodium_init (); zmq_assert (rc != -1); +#if defined(ZMQ_LIBSODIUM_RANDOMBYTES_CLOSE) } else { + // randombytes_close either a no-op or not threadsafe + // doing this without refcounting can cause crashes + // if called while a context is active randombytes_close (); +#endif } #else LIBZMQ_UNUSED (init_); diff --git a/deps/zmq/src/random.hpp b/deps/zmq/src/random.hpp index 0b57adb9614..6cba7f86a14 100644 --- a/deps/zmq/src/random.hpp +++ b/deps/zmq/src/random.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2017 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_RANDOM_HPP_INCLUDED__ #define __ZMQ_RANDOM_HPP_INCLUDED__ diff --git a/deps/zmq/src/raw_decoder.cpp b/deps/zmq/src/raw_decoder.cpp index 97ed7972d88..c29b6b0d48b 100644 --- a/deps/zmq/src/raw_decoder.cpp +++ b/deps/zmq/src/raw_decoder.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include diff --git a/deps/zmq/src/raw_decoder.hpp b/deps/zmq/src/raw_decoder.hpp index 4f6e83417e0..2e32cd96753 100644 --- a/deps/zmq/src/raw_decoder.hpp +++ b/deps/zmq/src/raw_decoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_RAW_DECODER_HPP_INCLUDED__ #define __ZMQ_RAW_DECODER_HPP_INCLUDED__ diff --git a/deps/zmq/src/raw_encoder.cpp b/deps/zmq/src/raw_encoder.cpp index 39c7633ee1f..ecb5cbe26f7 100644 --- a/deps/zmq/src/raw_encoder.cpp +++ b/deps/zmq/src/raw_encoder.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "encoder.hpp" diff --git a/deps/zmq/src/raw_encoder.hpp b/deps/zmq/src/raw_encoder.hpp index 0485e64a7c9..c0e7e467693 100644 --- a/deps/zmq/src/raw_encoder.hpp +++ b/deps/zmq/src/raw_encoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_RAW_ENCODER_HPP_INCLUDED__ #define __ZMQ_RAW_ENCODER_HPP_INCLUDED__ diff --git a/deps/zmq/src/raw_engine.cpp b/deps/zmq/src/raw_engine.cpp index 5910cd9968f..b0fc2209d55 100644 --- a/deps/zmq/src/raw_engine.cpp +++ b/deps/zmq/src/raw_engine.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -124,7 +97,7 @@ void zmq::raw_engine_t::error (error_reason_t reason_) // so that it knows the peer has been disconnected. msg_t terminator; terminator.init (); - (this->*_process_msg) (&terminator); + push_raw_msg_to_session (&terminator); terminator.close (); } stream_engine_base_t::error (reason_); diff --git a/deps/zmq/src/raw_engine.hpp b/deps/zmq/src/raw_engine.hpp index cf60bb6759d..bf8f1e179c8 100644 --- a/deps/zmq/src/raw_engine.hpp +++ b/deps/zmq/src/raw_engine.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_RAW_ENGINE_HPP_INCLUDED__ #define __ZMQ_RAW_ENGINE_HPP_INCLUDED__ diff --git a/deps/zmq/src/reaper.cpp b/deps/zmq/src/reaper.cpp index 525bf578af6..4361a7e97b6 100644 --- a/deps/zmq/src/reaper.cpp +++ b/deps/zmq/src/reaper.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" diff --git a/deps/zmq/src/reaper.hpp b/deps/zmq/src/reaper.hpp index 7b2d51cce34..61826cdd355 100644 --- a/deps/zmq/src/reaper.hpp +++ b/deps/zmq/src/reaper.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_REAPER_HPP_INCLUDED__ #define __ZMQ_REAPER_HPP_INCLUDED__ diff --git a/deps/zmq/src/rep.cpp b/deps/zmq/src/rep.cpp index 99707f89cfc..d018572d625 100644 --- a/deps/zmq/src/rep.cpp +++ b/deps/zmq/src/rep.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "rep.hpp" diff --git a/deps/zmq/src/rep.hpp b/deps/zmq/src/rep.hpp index 995fe40cf8f..85ef654ce5f 100644 --- a/deps/zmq/src/rep.hpp +++ b/deps/zmq/src/rep.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_REP_HPP_INCLUDED__ #define __ZMQ_REP_HPP_INCLUDED__ diff --git a/deps/zmq/src/req.cpp b/deps/zmq/src/req.cpp index b9bb35b0faa..6f95e294e01 100644 --- a/deps/zmq/src/req.cpp +++ b/deps/zmq/src/req.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -281,7 +254,7 @@ int zmq::req_session_t::push_msg (msg_t *msg_) case bottom: if (msg_->flags () == msg_t::more) { // In case option ZMQ_CORRELATE is on, allow request_id to be - // transfered as first frame (would be too cumbersome to check + // transferred as first frame (would be too cumbersome to check // whether the option is actually on or not). if (msg_->size () == sizeof (uint32_t)) { _state = request_id; diff --git a/deps/zmq/src/req.hpp b/deps/zmq/src/req.hpp index 0b0084cf9f5..2121661ba3b 100644 --- a/deps/zmq/src/req.hpp +++ b/deps/zmq/src/req.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_REQ_HPP_INCLUDED__ #define __ZMQ_REQ_HPP_INCLUDED__ diff --git a/deps/zmq/src/router.cpp b/deps/zmq/src/router.cpp index 77526e4e44e..53ec17c9d32 100644 --- a/deps/zmq/src/router.cpp +++ b/deps/zmq/src/router.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -401,6 +374,8 @@ bool zmq::router_t::xhas_in () errno_assert (rc == 0); memcpy (_prefetched_id.data (), routing_id.data (), routing_id.size ()); _prefetched_id.set_flags (msg_t::more); + if (_prefetched_msg.metadata ()) + _prefetched_id.set_metadata (_prefetched_msg.metadata ()); _prefetched = true; _routing_id_sent = false; @@ -418,7 +393,7 @@ bool zmq::router_t::xhas_out () { // In theory, ROUTER socket is always ready for writing (except when // MANDATORY is set). Whether actual attempt to write succeeds depends - // on whitch pipe the message is going to be routed to. + // on which pipe the message is going to be routed to. if (!_mandatory) return true; diff --git a/deps/zmq/src/router.hpp b/deps/zmq/src/router.hpp index f020672f24b..607d2113736 100644 --- a/deps/zmq/src/router.hpp +++ b/deps/zmq/src/router.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_ROUTER_HPP_INCLUDED__ #define __ZMQ_ROUTER_HPP_INCLUDED__ diff --git a/deps/zmq/src/scatter.cpp b/deps/zmq/src/scatter.cpp index b951b92e172..f7c9391cc8a 100644 --- a/deps/zmq/src/scatter.cpp +++ b/deps/zmq/src/scatter.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" diff --git a/deps/zmq/src/scatter.hpp b/deps/zmq/src/scatter.hpp index 5fd36a2b9fa..413551e9e83 100644 --- a/deps/zmq/src/scatter.hpp +++ b/deps/zmq/src/scatter.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_SCATTER_HPP_INCLUDED__ #define __ZMQ_SCATTER_HPP_INCLUDED__ diff --git a/deps/zmq/src/secure_allocator.hpp b/deps/zmq/src/secure_allocator.hpp index 0d37e7ed8ce..92bf1194479 100644 --- a/deps/zmq/src/secure_allocator.hpp +++ b/deps/zmq/src/secure_allocator.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_SECURE_ALLOCATOR_HPP_INCLUDED__ #define __ZMQ_SECURE_ALLOCATOR_HPP_INCLUDED__ @@ -60,7 +33,11 @@ template struct secure_allocator_t alloc_assert (res); return res; } - void deallocate (T *p, std::size_t) ZMQ_NOEXCEPT { sodium_free (p); } + void deallocate (T *p, std::size_t) ZMQ_NOEXCEPT + { + if (p) + sodium_free (p); + } // the following is only required with C++98 // TODO maybe make this conditionally compiled @@ -95,6 +72,17 @@ bool operator!= (const secure_allocator_t &, const secure_allocator_t &) #else template struct secure_allocator_t : std::allocator { + secure_allocator_t () ZMQ_DEFAULT; + + template + secure_allocator_t (const secure_allocator_t &) ZMQ_NOEXCEPT + { + } + + template struct rebind + { + typedef secure_allocator_t other; + }; }; #endif } diff --git a/deps/zmq/src/select.cpp b/deps/zmq/src/select.cpp index 159f44f235c..8673215bf92 100644 --- a/deps/zmq/src/select.cpp +++ b/deps/zmq/src/select.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "select.hpp" @@ -477,8 +450,8 @@ zmq::select_t::fds_set_t::fds_set_t (const fds_set_t &other_) #endif } -zmq::select_t::fds_set_t &zmq::select_t::fds_set_t:: -operator= (const fds_set_t &other_) +zmq::select_t::fds_set_t & +zmq::select_t::fds_set_t::operator= (const fds_set_t &other_) { #if defined ZMQ_HAVE_WINDOWS // On Windows we don't need to copy the whole fd_set. diff --git a/deps/zmq/src/select.hpp b/deps/zmq/src/select.hpp index 8f18a383f7b..34f260ecbbd 100644 --- a/deps/zmq/src/select.hpp +++ b/deps/zmq/src/select.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_SELECT_HPP_INCLUDED__ #define __ZMQ_SELECT_HPP_INCLUDED__ diff --git a/deps/zmq/src/server.cpp b/deps/zmq/src/server.cpp index 6f0cf26927f..f458bfae63f 100644 --- a/deps/zmq/src/server.cpp +++ b/deps/zmq/src/server.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" diff --git a/deps/zmq/src/server.hpp b/deps/zmq/src/server.hpp index cef1e4d26cd..e91edf8eb51 100644 --- a/deps/zmq/src/server.hpp +++ b/deps/zmq/src/server.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_SERVER_HPP_INCLUDED__ #define __ZMQ_SERVER_HPP_INCLUDED__ diff --git a/deps/zmq/src/session_base.cpp b/deps/zmq/src/session_base.cpp index 551ae318f3c..5a81b076d48 100644 --- a/deps/zmq/src/session_base.cpp +++ b/deps/zmq/src/session_base.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -460,14 +433,18 @@ void zmq::session_base_t::engine_error (bool handshaked_, if (_pipe) { clean_pipes (); -#ifdef ZMQ_BUILD_DRAFT_API // Only send disconnect message if socket was accepted and handshake was completed if (!_active && handshaked_ && options.can_recv_disconnect_msg && !options.disconnect_msg.empty ()) { _pipe->set_disconnect_msg (options.disconnect_msg); _pipe->send_disconnect_msg (); } -#endif + + // Only send hiccup message if socket was connected and handshake was completed + if (_active && handshaked_ && options.can_recv_hiccup_msg + && !options.hiccup_msg.empty ()) { + _pipe->send_hiccup_msg (options.hiccup_msg); + } } zmq_assert (reason_ == i_engine::connection_error diff --git a/deps/zmq/src/session_base.hpp b/deps/zmq/src/session_base.hpp index c2e6d098522..ca3bc668d81 100644 --- a/deps/zmq/src/session_base.hpp +++ b/deps/zmq/src/session_base.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_SESSION_BASE_HPP_INCLUDED__ #define __ZMQ_SESSION_BASE_HPP_INCLUDED__ @@ -113,7 +86,7 @@ class session_base_t : public own_t, public io_object_t, public i_pipe_events void process_plug () ZMQ_FINAL; void process_attach (zmq::i_engine *engine_) ZMQ_FINAL; void process_term (int linger_) ZMQ_FINAL; - void process_conn_failed (); + void process_conn_failed () ZMQ_OVERRIDE; // i_poll_events handlers. void timer_event (int id_) ZMQ_FINAL; diff --git a/deps/zmq/src/signaler.cpp b/deps/zmq/src/signaler.cpp index 93fb248e18c..64692db6b37 100644 --- a/deps/zmq/src/signaler.cpp +++ b/deps/zmq/src/signaler.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "poller.hpp" diff --git a/deps/zmq/src/signaler.hpp b/deps/zmq/src/signaler.hpp index 49fac1bad47..8cb8cc89cf1 100644 --- a/deps/zmq/src/signaler.hpp +++ b/deps/zmq/src/signaler.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_SIGNALER_HPP_INCLUDED__ #define __ZMQ_SIGNALER_HPP_INCLUDED__ diff --git a/deps/zmq/src/socket_base.cpp b/deps/zmq/src/socket_base.cpp index bbb378cc793..5a9adcdeead 100644 --- a/deps/zmq/src/socket_base.cpp +++ b/deps/zmq/src/socket_base.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -460,6 +433,12 @@ int zmq::socket_base_t::getsockopt (int option_, return -1; } + // First, check whether specific socket type overloads the option. + int rc = xgetsockopt (option_, optval_, optvallen_); + if (rc == 0 || errno != EINVAL) { + return rc; + } + if (option_ == ZMQ_RCVMORE) { return do_getsockopt (optval_, optvallen_, _rcvmore ? 1 : 0); } @@ -804,16 +783,14 @@ int zmq::socket_base_t::connect_internal (const char *endpoint_uri_) // The total HWM for an inproc connection should be the sum of // the binder's HWM and the connector's HWM. - const int sndhwm = peer.socket == NULL - ? options.sndhwm - : options.sndhwm != 0 && peer.options.rcvhwm != 0 - ? options.sndhwm + peer.options.rcvhwm - : 0; - const int rcvhwm = peer.socket == NULL - ? options.rcvhwm - : options.rcvhwm != 0 && peer.options.sndhwm != 0 - ? options.rcvhwm + peer.options.sndhwm - : 0; + const int sndhwm = peer.socket == NULL ? options.sndhwm + : options.sndhwm != 0 && peer.options.rcvhwm != 0 + ? options.sndhwm + peer.options.rcvhwm + : 0; + const int rcvhwm = peer.socket == NULL ? options.rcvhwm + : options.rcvhwm != 0 && peer.options.sndhwm != 0 + ? options.rcvhwm + peer.options.sndhwm + : 0; // Create a bi-directional pipe to connect the peers. object_t *parents[2] = {this, peer.socket == NULL ? this : peer.socket}; @@ -1500,15 +1477,17 @@ int zmq::socket_base_t::process_commands (int timeout_, bool throttle_) command_t cmd; int rc = _mailbox->recv (&cmd, timeout_); + if (rc != 0 && errno == EINTR) + return -1; + // Process all available commands. - while (rc == 0) { - cmd.destination->process_command (cmd); + while (rc == 0 || errno == EINTR) { + if (rc == 0) { + cmd.destination->process_command (cmd); + } rc = _mailbox->recv (&cmd, 0); } - if (errno == EINTR) - return -1; - zmq_assert (errno == EAGAIN); if (_ctx_terminated) { @@ -1621,6 +1600,12 @@ int zmq::socket_base_t::xsetsockopt (int, const void *, size_t) return -1; } +int zmq::socket_base_t::xgetsockopt (int, void *, size_t *) +{ + errno = EINVAL; + return -1; +} + bool zmq::socket_base_t::xhas_out () { return false; diff --git a/deps/zmq/src/socket_base.hpp b/deps/zmq/src/socket_base.hpp index 92deb9f71a4..e539d50b6b2 100644 --- a/deps/zmq/src/socket_base.hpp +++ b/deps/zmq/src/socket_base.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_SOCKET_BASE_HPP_INCLUDED__ #define __ZMQ_SOCKET_BASE_HPP_INCLUDED__ @@ -186,6 +159,11 @@ class socket_base_t : public own_t, virtual int xsetsockopt (int option_, const void *optval_, size_t optvallen_); + // The default implementation assumes there are no specific socket + // options for the particular socket type. If not so, ZMQ_FINAL this + // method. + virtual int xgetsockopt (int option_, void *optval_, size_t *optvallen_); + // The default implementation assumes that send is not supported. virtual bool xhas_out (); virtual int xsend (zmq::msg_t *msg_); diff --git a/deps/zmq/src/socket_poller.cpp b/deps/zmq/src/socket_poller.cpp index eecbf16b7c5..b5c330e8b22 100644 --- a/deps/zmq/src/socket_poller.cpp +++ b/deps/zmq/src/socket_poller.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "socket_poller.hpp" diff --git a/deps/zmq/src/socket_poller.hpp b/deps/zmq/src/socket_poller.hpp index 6f4923e77d8..3e71b44ce45 100644 --- a/deps/zmq/src/socket_poller.hpp +++ b/deps/zmq/src/socket_poller.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_SOCKET_POLLER_HPP_INCLUDED__ #define __ZMQ_SOCKET_POLLER_HPP_INCLUDED__ diff --git a/deps/zmq/src/socks.cpp b/deps/zmq/src/socks.cpp index 9da12be63d7..a910e5575d0 100644 --- a/deps/zmq/src/socks.cpp +++ b/deps/zmq/src/socks.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -55,8 +28,7 @@ zmq::socks_greeting_t::socks_greeting_t (const uint8_t *methods_, } zmq::socks_greeting_encoder_t::socks_greeting_encoder_t () : - _bytes_encoded (0), - _bytes_written (0) + _bytes_encoded (0), _bytes_written (0) { } @@ -131,8 +103,7 @@ void zmq::socks_choice_decoder_t::reset () zmq::socks_basic_auth_request_t::socks_basic_auth_request_t ( const std::string &username_, const std::string &password_) : - username (username_), - password (password_) + username (username_), password (password_) { zmq_assert (username_.size () <= UINT8_MAX); zmq_assert (password_.size () <= UINT8_MAX); @@ -140,8 +111,7 @@ zmq::socks_basic_auth_request_t::socks_basic_auth_request_t ( zmq::socks_basic_auth_request_encoder_t::socks_basic_auth_request_encoder_t () : - _bytes_encoded (0), - _bytes_written (0) + _bytes_encoded (0), _bytes_written (0) { } @@ -223,16 +193,13 @@ void zmq::socks_auth_response_decoder_t::reset () zmq::socks_request_t::socks_request_t (uint8_t command_, std::string hostname_, uint16_t port_) : - command (command_), - hostname (ZMQ_MOVE (hostname_)), - port (port_) + command (command_), hostname (ZMQ_MOVE (hostname_)), port (port_) { zmq_assert (hostname.size () <= UINT8_MAX); } zmq::socks_request_encoder_t::socks_request_encoder_t () : - _bytes_encoded (0), - _bytes_written (0) + _bytes_encoded (0), _bytes_written (0) { } @@ -308,9 +275,7 @@ void zmq::socks_request_encoder_t::reset () zmq::socks_response_t::socks_response_t (uint8_t response_code_, const std::string &address_, uint16_t port_) : - response_code (response_code_), - address (address_), - port (port_) + response_code (response_code_), address (address_), port (port_) { } diff --git a/deps/zmq/src/socks.hpp b/deps/zmq/src/socks.hpp index bc3d5e2f752..704ac6c00ee 100644 --- a/deps/zmq/src/socks.hpp +++ b/deps/zmq/src/socks.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_SOCKS_HPP_INCLUDED__ #define __ZMQ_SOCKS_HPP_INCLUDED__ diff --git a/deps/zmq/src/socks_connecter.cpp b/deps/zmq/src/socks_connecter.cpp index b2931605c80..e2d25e5d0c8 100644 --- a/deps/zmq/src/socks_connecter.cpp +++ b/deps/zmq/src/socks_connecter.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include diff --git a/deps/zmq/src/socks_connecter.hpp b/deps/zmq/src/socks_connecter.hpp index de79415c901..8aa0bee6d8f 100644 --- a/deps/zmq/src/socks_connecter.hpp +++ b/deps/zmq/src/socks_connecter.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __SOCKS_CONNECTER_HPP_INCLUDED__ #define __SOCKS_CONNECTER_HPP_INCLUDED__ diff --git a/deps/zmq/src/stdint.hpp b/deps/zmq/src/stdint.hpp index dc4d5df1f70..668edd255ed 100644 --- a/deps/zmq/src/stdint.hpp +++ b/deps/zmq/src/stdint.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_STDINT_HPP_INCLUDED__ #define __ZMQ_STDINT_HPP_INCLUDED__ diff --git a/deps/zmq/src/stream.cpp b/deps/zmq/src/stream.cpp index 3713c7e7d79..7d10b62b862 100644 --- a/deps/zmq/src/stream.cpp +++ b/deps/zmq/src/stream.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" diff --git a/deps/zmq/src/stream.hpp b/deps/zmq/src/stream.hpp index b5ea24cdd50..f8eb9901e32 100644 --- a/deps/zmq/src/stream.hpp +++ b/deps/zmq/src/stream.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_STREAM_HPP_INCLUDED__ #define __ZMQ_STREAM_HPP_INCLUDED__ diff --git a/deps/zmq/src/stream_connecter_base.cpp b/deps/zmq/src/stream_connecter_base.cpp index 138d7d61024..8dd9a6d69fc 100644 --- a/deps/zmq/src/stream_connecter_base.cpp +++ b/deps/zmq/src/stream_connecter_base.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "stream_connecter_base.hpp" @@ -57,7 +30,7 @@ zmq::stream_connecter_base_t::stream_connecter_base_t ( _socket (session_->get_socket ()), _delayed_start (delayed_start_), _reconnect_timer_started (false), - _current_reconnect_ivl (options.reconnect_ivl), + _current_reconnect_ivl (-1), _session (session_) { zmq_assert (_addr); @@ -112,29 +85,32 @@ void zmq::stream_connecter_base_t::add_reconnect_timer () int zmq::stream_connecter_base_t::get_new_reconnect_ivl () { - // TODO should the random jitter be really based on the configured initial - // reconnect interval options.reconnect_ivl, or better on the - // _current_reconnect_ivl? - - // The new interval is the current interval + random value. - const int random_jitter = generate_random () % options.reconnect_ivl; - const int interval = - _current_reconnect_ivl < std::numeric_limits::max () - random_jitter - ? _current_reconnect_ivl + random_jitter - : std::numeric_limits::max (); - - // Only change the new current reconnect interval if the maximum reconnect - // interval was set and if it's larger than the reconnect interval. - if (options.reconnect_ivl_max > 0 - && options.reconnect_ivl_max > options.reconnect_ivl) { - // Calculate the next interval - _current_reconnect_ivl = - _current_reconnect_ivl < std::numeric_limits::max () / 2 - ? std::min (_current_reconnect_ivl * 2, options.reconnect_ivl_max) - : options.reconnect_ivl_max; + if (options.reconnect_ivl_max > 0) { + int candidate_interval = 0; + if (_current_reconnect_ivl == -1) + candidate_interval = options.reconnect_ivl; + else if (_current_reconnect_ivl > std::numeric_limits::max () / 2) + candidate_interval = std::numeric_limits::max (); + else + candidate_interval = _current_reconnect_ivl * 2; + + if (candidate_interval > options.reconnect_ivl_max) + _current_reconnect_ivl = options.reconnect_ivl_max; + else + _current_reconnect_ivl = candidate_interval; + return _current_reconnect_ivl; + } else { + if (_current_reconnect_ivl == -1) + _current_reconnect_ivl = options.reconnect_ivl; + // The new interval is the base interval + random value. + const int random_jitter = generate_random () % options.reconnect_ivl; + const int interval = + _current_reconnect_ivl + < std::numeric_limits::max () - random_jitter + ? _current_reconnect_ivl + random_jitter + : std::numeric_limits::max (); + return interval; } - - return interval; } void zmq::stream_connecter_base_t::rm_handle () diff --git a/deps/zmq/src/stream_connecter_base.hpp b/deps/zmq/src/stream_connecter_base.hpp index 008c90147c9..78de107ffc7 100644 --- a/deps/zmq/src/stream_connecter_base.hpp +++ b/deps/zmq/src/stream_connecter_base.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __STREAM_CONNECTER_BASE_HPP_INCLUDED__ #define __STREAM_CONNECTER_BASE_HPP_INCLUDED__ diff --git a/deps/zmq/src/stream_engine_base.cpp b/deps/zmq/src/stream_engine_base.cpp index bb64e0db055..71e09b1ba04 100644 --- a/deps/zmq/src/stream_engine_base.cpp +++ b/deps/zmq/src/stream_engine_base.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -255,8 +228,14 @@ bool zmq::stream_engine_base_t::in_event_internal () // Switch into the normal message flow. _handshaking = false; - if (_mechanism == NULL && _has_handshake_stage) + if (_mechanism == NULL && _has_handshake_stage) { _session->engine_ready (); + + if (_has_handshake_timer) { + cancel_timer (handshake_timer_id); + _has_handshake_timer = false; + } + } } else return false; } diff --git a/deps/zmq/src/stream_engine_base.hpp b/deps/zmq/src/stream_engine_base.hpp index 58bf9579373..1100cae087b 100644 --- a/deps/zmq/src/stream_engine_base.hpp +++ b/deps/zmq/src/stream_engine_base.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_STREAM_ENGINE_BASE_HPP_INCLUDED__ #define __ZMQ_STREAM_ENGINE_BASE_HPP_INCLUDED__ @@ -73,7 +46,7 @@ class stream_engine_base_t : public io_object_t, public i_engine // i_poll_events interface implementation. void in_event () ZMQ_FINAL; - void out_event (); + void out_event () ZMQ_OVERRIDE; void timer_event (int id_) ZMQ_FINAL; protected: diff --git a/deps/zmq/src/stream_listener_base.cpp b/deps/zmq/src/stream_listener_base.cpp index ecd21be085d..350093ad016 100644 --- a/deps/zmq/src/stream_listener_base.cpp +++ b/deps/zmq/src/stream_listener_base.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "stream_listener_base.hpp" diff --git a/deps/zmq/src/stream_listener_base.hpp b/deps/zmq/src/stream_listener_base.hpp index 71582541bc5..1a4f62ff9a8 100644 --- a/deps/zmq/src/stream_listener_base.hpp +++ b/deps/zmq/src/stream_listener_base.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_STREAM_LISTENER_BASE_HPP_INCLUDED__ #define __ZMQ_STREAM_LISTENER_BASE_HPP_INCLUDED__ diff --git a/deps/zmq/src/sub.cpp b/deps/zmq/src/sub.cpp index 7240054ab7a..903e7dc8a0d 100644 --- a/deps/zmq/src/sub.cpp +++ b/deps/zmq/src/sub.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "sub.hpp" diff --git a/deps/zmq/src/sub.hpp b/deps/zmq/src/sub.hpp index ee519c89f16..6fac7262006 100644 --- a/deps/zmq/src/sub.hpp +++ b/deps/zmq/src/sub.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_SUB_HPP_INCLUDED__ #define __ZMQ_SUB_HPP_INCLUDED__ diff --git a/deps/zmq/src/tcp.cpp b/deps/zmq/src/tcp.cpp index c37bed02500..adebea62d50 100644 --- a/deps/zmq/src/tcp.cpp +++ b/deps/zmq/src/tcp.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -341,6 +314,21 @@ void zmq::tcp_tune_loopback_fast_path (const fd_t socket_) #endif } +void zmq::tune_tcp_busy_poll (fd_t socket_, int busy_poll_) +{ +#if defined(ZMQ_HAVE_BUSY_POLL) + if (busy_poll_ > 0) { + const int rc = + setsockopt (socket_, SOL_SOCKET, SO_BUSY_POLL, + reinterpret_cast (&busy_poll_), sizeof (int)); + assert_success_or_recoverable (socket_, rc); + } +#else + LIBZMQ_UNUSED (socket_); + LIBZMQ_UNUSED (busy_poll_); +#endif +} + zmq::fd_t zmq::tcp_open_socket (const char *address_, const zmq::options_t &options_, bool local_, @@ -398,6 +386,9 @@ zmq::fd_t zmq::tcp_open_socket (const char *address_, if (options_.rcvbuf >= 0) set_tcp_receive_buffer (s, options_.rcvbuf); + // This option removes several delays caused by scheduling, interrupts and context switching. + if (options_.busy_poll) + tune_tcp_busy_poll (s, options_.busy_poll); return s; setsockopt_error: diff --git a/deps/zmq/src/tcp.hpp b/deps/zmq/src/tcp.hpp index fc355a6348e..c6b24f5643f 100644 --- a/deps/zmq/src/tcp.hpp +++ b/deps/zmq/src/tcp.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_TCP_HPP_INCLUDED__ #define __ZMQ_TCP_HPP_INCLUDED__ @@ -68,6 +41,8 @@ int tcp_read (fd_t s_, void *data_, size_t size_); void tcp_tune_loopback_fast_path (fd_t socket_); +void tune_tcp_busy_poll (fd_t socket_, int busy_poll_); + // Resolves the given address_ string, opens a socket and sets socket options // according to the passed options_. On success, returns the socket // descriptor and assigns the resolved address to out_tcp_addr_. In case of diff --git a/deps/zmq/src/tcp_address.cpp b/deps/zmq/src/tcp_address.cpp index bdda66a2002..93eab84e6cf 100644 --- a/deps/zmq/src/tcp_address.cpp +++ b/deps/zmq/src/tcp_address.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -102,7 +75,7 @@ int zmq::tcp_address_t::resolve (const char *name_, bool local_, bool ipv6_) ip_resolver_options_t resolver_opts; resolver_opts.bindable (local_) - .allow_dns (!local_) + .allow_dns (true) .allow_nic_name (local_) .ipv6 (ipv6_) .expect_port (true); @@ -129,7 +102,9 @@ static std::string make_address_string (const char *hbuf_, pos += hbuf_len; memcpy (pos, ipv6_suffix_, sizeof ipv6_suffix_ - 1); pos += sizeof ipv6_suffix_ - 1; - pos += sprintf (pos, "%d", ntohs (port_)); + int res = snprintf (pos, max_port_str_length + 1, "%d", ntohs (port_)); + zmq_assert (res > 0 && res < (int) (max_port_str_length + 1)); + pos += res; return std::string (buf, pos - buf); } diff --git a/deps/zmq/src/tcp_address.hpp b/deps/zmq/src/tcp_address.hpp index 4d3edf494b3..c3f7bff1daa 100644 --- a/deps/zmq/src/tcp_address.hpp +++ b/deps/zmq/src/tcp_address.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_TCP_ADDRESS_HPP_INCLUDED__ #define __ZMQ_TCP_ADDRESS_HPP_INCLUDED__ diff --git a/deps/zmq/src/tcp_connecter.cpp b/deps/zmq/src/tcp_connecter.cpp index a0138eb1af9..0dbf5863720 100644 --- a/deps/zmq/src/tcp_connecter.cpp +++ b/deps/zmq/src/tcp_connecter.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include diff --git a/deps/zmq/src/tcp_connecter.hpp b/deps/zmq/src/tcp_connecter.hpp index 49477039646..39be80a83bb 100644 --- a/deps/zmq/src/tcp_connecter.hpp +++ b/deps/zmq/src/tcp_connecter.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __TCP_CONNECTER_HPP_INCLUDED__ #define __TCP_CONNECTER_HPP_INCLUDED__ diff --git a/deps/zmq/src/tcp_listener.cpp b/deps/zmq/src/tcp_listener.cpp index 69581b74982..bb9804b08ba 100644 --- a/deps/zmq/src/tcp_listener.cpp +++ b/deps/zmq/src/tcp_listener.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include diff --git a/deps/zmq/src/tcp_listener.hpp b/deps/zmq/src/tcp_listener.hpp index 3f41b8fb98a..b489191a1c7 100644 --- a/deps/zmq/src/tcp_listener.hpp +++ b/deps/zmq/src/tcp_listener.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_TCP_LISTENER_HPP_INCLUDED__ #define __ZMQ_TCP_LISTENER_HPP_INCLUDED__ diff --git a/deps/zmq/src/thread.cpp b/deps/zmq/src/thread.cpp index c754e9cd9f9..e013a778cfa 100644 --- a/deps/zmq/src/thread.cpp +++ b/deps/zmq/src/thread.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -36,6 +9,10 @@ #include #endif +#ifdef __MINGW32__ +#include "pthread.h" +#endif + bool zmq::thread_t::get_started () const { return _started; @@ -111,6 +88,8 @@ void zmq::thread_t:: // not implemented } +#ifdef _MSC_VER + namespace { #pragma pack(push, 8) @@ -124,22 +103,7 @@ struct thread_info_t #pragma pack(pop) } -struct MY_EXCEPTION_REGISTRATION_RECORD -{ - typedef EXCEPTION_DISPOSITION (NTAPI *HandlerFunctionType) ( - EXCEPTION_RECORD *, void *, CONTEXT *, void *); - - MY_EXCEPTION_REGISTRATION_RECORD *Next; - HandlerFunctionType Handler; -}; - -static EXCEPTION_DISPOSITION NTAPI continue_execution (EXCEPTION_RECORD *rec, - void *frame, - CONTEXT *ctx, - void *disp) -{ - return ExceptionContinueExecution; -} +#endif void zmq::thread_t:: applyThreadName () // to be called in secondary thread context @@ -147,29 +111,37 @@ void zmq::thread_t:: if (!_name[0] || !IsDebuggerPresent ()) return; +#ifdef _MSC_VER + thread_info_t thread_info; thread_info._type = 0x1000; thread_info._name = _name; thread_info._thread_id = -1; thread_info._flags = 0; - NT_TIB *tib = ((NT_TIB *) NtCurrentTeb ()); - - MY_EXCEPTION_REGISTRATION_RECORD rec; - rec.Next = (MY_EXCEPTION_REGISTRATION_RECORD *) tib->ExceptionList; - rec.Handler = continue_execution; - - // push our handler, raise, and finally pop our handler - tib->ExceptionList = (_EXCEPTION_REGISTRATION_RECORD *) &rec; - const DWORD MS_VC_EXCEPTION = 0x406D1388; - RaiseException (MS_VC_EXCEPTION, 0, - sizeof (thread_info) / sizeof (ULONG_PTR), - (ULONG_PTR *) &thread_info); - tib->ExceptionList = - (_EXCEPTION_REGISTRATION_RECORD - *) (((MY_EXCEPTION_REGISTRATION_RECORD *) tib->ExceptionList)->Next); + __try { + const DWORD MS_VC_EXCEPTION = 0x406D1388; + RaiseException (MS_VC_EXCEPTION, 0, + sizeof (thread_info) / sizeof (ULONG_PTR), + (ULONG_PTR *) &thread_info); + } + __except (EXCEPTION_CONTINUE_EXECUTION) { + } + +#elif defined(__MINGW32__) + + int rc = pthread_setname_np (pthread_self (), _name); + if (rc) + return; + +#else + + // not implemented + +#endif } + #elif defined ZMQ_HAVE_VXWORKS extern "C" { @@ -280,7 +252,7 @@ void zmq::thread_t::stop () bool zmq::thread_t::is_current_thread () const { - return bool(pthread_equal (pthread_self (), _descriptor)); + return bool (pthread_equal (pthread_self (), _descriptor)); } void zmq::thread_t::setSchedulingParameters ( @@ -320,14 +292,12 @@ void zmq::thread_t:: bool use_nice_instead_priority = (policy != SCHED_FIFO) && (policy != SCHED_RR); - if (_thread_priority != ZMQ_THREAD_PRIORITY_DFLT) { - if (use_nice_instead_priority) - param.sched_priority = - 0; // this is the only supported priority for most scheduling policies - else - param.sched_priority = - _thread_priority; // user should provide a value between 1 and 99 - } + if (use_nice_instead_priority) + param.sched_priority = + 0; // this is the only supported priority for most scheduling policies + else if (_thread_priority != ZMQ_THREAD_PRIORITY_DFLT) + param.sched_priority = + _thread_priority; // user should provide a value between 1 and 99 #ifdef __NetBSD__ if (policy == SCHED_OTHER) @@ -346,7 +316,8 @@ void zmq::thread_t:: #if !defined ZMQ_HAVE_VXWORKS if (use_nice_instead_priority - && _thread_priority != ZMQ_THREAD_PRIORITY_DFLT) { + && _thread_priority != ZMQ_THREAD_PRIORITY_DFLT + && _thread_priority > 0) { // assume the user wants to decrease the thread's nice value // i.e., increase the chance of this thread being scheduled: try setting that to // maximum priority. diff --git a/deps/zmq/src/thread.hpp b/deps/zmq/src/thread.hpp index 256bfef3cd5..955b227d908 100644 --- a/deps/zmq/src/thread.hpp +++ b/deps/zmq/src/thread.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_THREAD_HPP_INCLUDED__ #define __ZMQ_THREAD_HPP_INCLUDED__ @@ -41,7 +14,7 @@ namespace zmq { -typedef void(thread_fn) (void *); +typedef void (thread_fn) (void *); // Class encapsulating OS thread. Thread initiation/termination is done // using special functions rather than in constructor/destructor so that diff --git a/deps/zmq/src/timers.cpp b/deps/zmq/src/timers.cpp index e9b516e039f..0aeb7befe93 100644 --- a/deps/zmq/src/timers.cpp +++ b/deps/zmq/src/timers.cpp @@ -1,31 +1,4 @@ -/* -Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - -This file is part of libzmq, the ZeroMQ core engine in C++. - -libzmq is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser General Public License (LGPL) as published -by the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -As a special exception, the Contributors give you permission to link -this library with independent modules to produce an executable, -regardless of the license terms of these independent modules, and to -copy and distribute the resulting executable under terms of your choice, -provided that you also meet, for each linked independent module, the -terms and conditions of the license of that module. An independent -module is a module which is not derived from or based on this library. -If you modify this library, you must extend this exception to your -version of the library. - -libzmq is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "timers.hpp" diff --git a/deps/zmq/src/timers.hpp b/deps/zmq/src/timers.hpp index 384d5e3f111..dbc9b8dcc8d 100644 --- a/deps/zmq/src/timers.hpp +++ b/deps/zmq/src/timers.hpp @@ -1,31 +1,4 @@ -/* -Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - -This file is part of libzmq, the ZeroMQ core engine in C++. - -libzmq is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser General Public License (LGPL) as published -by the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -As a special exception, the Contributors give you permission to link -this library with independent modules to produce an executable, -regardless of the license terms of these independent modules, and to -copy and distribute the resulting executable under terms of your choice, -provided that you also meet, for each linked independent module, the -terms and conditions of the license of that module. An independent -module is a module which is not derived from or based on this library. -If you modify this library, you must extend this exception to your -version of the library. - -libzmq is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_TIMERS_HPP_INCLUDED__ #define __ZMQ_TIMERS_HPP_INCLUDED__ @@ -38,7 +11,7 @@ along with this program. If not, see . namespace zmq { -typedef void(timers_timer_fn) (int timer_id_, void *arg_); +typedef void (timers_timer_fn) (int timer_id_, void *arg_); class timers_t { diff --git a/deps/zmq/src/tipc_address.cpp b/deps/zmq/src/tipc_address.cpp index 758b6a56fff..3fb67fb7a58 100644 --- a/deps/zmq/src/tipc_address.cpp +++ b/deps/zmq/src/tipc_address.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" diff --git a/deps/zmq/src/tipc_address.hpp b/deps/zmq/src/tipc_address.hpp index 55ae0e7dcc8..db6f88aca3d 100644 --- a/deps/zmq/src/tipc_address.hpp +++ b/deps/zmq/src/tipc_address.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_TIPC_ADDRESS_HPP_INCLUDED__ #define __ZMQ_TIPC_ADDRESS_HPP_INCLUDED__ diff --git a/deps/zmq/src/tipc_connecter.cpp b/deps/zmq/src/tipc_connecter.cpp index 6057997f6de..9d4e8263c62 100644 --- a/deps/zmq/src/tipc_connecter.cpp +++ b/deps/zmq/src/tipc_connecter.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" diff --git a/deps/zmq/src/tipc_connecter.hpp b/deps/zmq/src/tipc_connecter.hpp index e12643ff945..fd7f630cc80 100644 --- a/deps/zmq/src/tipc_connecter.hpp +++ b/deps/zmq/src/tipc_connecter.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __TIPC_CONNECTER_HPP_INCLUDED__ #define __TIPC_CONNECTER_HPP_INCLUDED__ diff --git a/deps/zmq/src/tipc_listener.cpp b/deps/zmq/src/tipc_listener.cpp index 338327bc1cd..c0cef6b43a5 100644 --- a/deps/zmq/src/tipc_listener.cpp +++ b/deps/zmq/src/tipc_listener.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" diff --git a/deps/zmq/src/tipc_listener.hpp b/deps/zmq/src/tipc_listener.hpp index 040a99e6f80..dd569c9f9d9 100644 --- a/deps/zmq/src/tipc_listener.hpp +++ b/deps/zmq/src/tipc_listener.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_TIPC_LISTENER_HPP_INCLUDED__ #define __ZMQ_TIPC_LISTENER_HPP_INCLUDED__ diff --git a/deps/zmq/src/trie.cpp b/deps/zmq/src/trie.cpp index 3c1e85651d9..548ae4d22c4 100644 --- a/deps/zmq/src/trie.cpp +++ b/deps/zmq/src/trie.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" diff --git a/deps/zmq/src/trie.hpp b/deps/zmq/src/trie.hpp index 32a2c2cb72c..f7ca14aec52 100644 --- a/deps/zmq/src/trie.hpp +++ b/deps/zmq/src/trie.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_TRIE_HPP_INCLUDED__ #define __ZMQ_TRIE_HPP_INCLUDED__ @@ -34,6 +7,7 @@ #include "macros.hpp" #include "stdint.hpp" +#include "atomic_counter.hpp" namespace zmq { @@ -80,6 +54,53 @@ class trie_t ZMQ_NON_COPYABLE_NOR_MOVABLE (trie_t) }; + + +// lightweight wrapper around trie_t adding tracking of total number of prefixes +class trie_with_size_t +{ + public: + trie_with_size_t () {} + ~trie_with_size_t () {} + + bool add (unsigned char *prefix_, size_t size_) + { + if (_trie.add (prefix_, size_)) { + _num_prefixes.add (1); + return true; + } else + return false; + } + + bool rm (unsigned char *prefix_, size_t size_) + { + if (_trie.rm (prefix_, size_)) { + _num_prefixes.sub (1); + return true; + } else + return false; + } + + bool check (const unsigned char *data_, size_t size_) const + { + return _trie.check (data_, size_); + } + + void apply (void (*func_) (unsigned char *data_, size_t size_, void *arg_), + void *arg_) + { + _trie.apply (func_, arg_); + } + + // Retrieve the number of prefixes stored in this trie (added - removed) + // Note this is a multithread safe function. + uint32_t num_prefixes () const { return _num_prefixes.get (); } + + private: + atomic_counter_t _num_prefixes; + trie_t _trie; +}; + } #endif diff --git a/deps/zmq/src/tweetnacl.c b/deps/zmq/src/tweetnacl.c deleted file mode 100644 index 6e6f657cf1c..00000000000 --- a/deps/zmq/src/tweetnacl.c +++ /dev/null @@ -1,993 +0,0 @@ -/* - Copyright (c) 2016-2017 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ - -/* - The precompiled header is not used for c files so this is required here. -*/ -#include "platform.hpp" - -#if defined(ZMQ_USE_TWEETNACL) - -/* - Disable warnings for this source only, rather than for the whole - codebase when building with C99 (gcc >= 4.2) or with Microsoft's compiler -*/ -#if defined __GNUC__ \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) \ - && __STDC_VERSION__ < 201112L -#pragma GCC diagnostic ignored "-Wsign-compare" -#elif defined _MSC_VER -#pragma warning(disable : 4018 4244 4146) -#endif - -/* clang-format off */ - -#include "tweetnacl.h" - -#define FOR(i,n) for (i = 0;i < n;++i) -#define sv static void - -static const u8 - _0[16], - _9[32] = {9}; -static const gf - gf0, - gf1 = {1}, - _121665 = {0xDB41,1}, - D = {0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203}, - D2 = {0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406}, - X = {0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169}, - Y = {0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666}, - I = {0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83}; - -static u32 L32(u32 x,int c) { return (x << c) | ((x&0xffffffff) >> (32 - c)); } - -static u32 ld32(const u8 *x) -{ - u32 u = x[3]; - u = (u<<8)|x[2]; - u = (u<<8)|x[1]; - return (u<<8)|x[0]; -} - -static u64 dl64(const u8 *x) -{ - u64 i,u=0; - FOR(i,8) u=(u<<8)|x[i]; - return u; -} - -sv st32(u8 *x,u32 u) -{ - int i; - FOR(i,4) { x[i] = u; u >>= 8; } -} - -sv ts64(u8 *x,u64 u) -{ - int i; - for (i = 7;i >= 0;--i) { x[i] = u; u >>= 8; } -} - -static int vn(const u8 *x,const u8 *y,int n) -{ - u32 i,d = 0; - FOR(i,n) d |= x[i]^y[i]; - return (1 & ((d - 1) >> 8)) - 1; -} - -int crypto_verify_16(const u8 *x,const u8 *y) -{ - return vn(x,y,16); -} - -int crypto_verify_32(const u8 *x,const u8 *y) -{ - return vn(x,y,32); -} - -sv core(u8 *out,const u8 *in,const u8 *k,const u8 *c,int h) -{ - u32 w[16],x[16],y[16],t[4]; - int i,j,m; - - FOR(i,4) { - x[5*i] = ld32(c+4*i); - x[1+i] = ld32(k+4*i); - x[6+i] = ld32(in+4*i); - x[11+i] = ld32(k+16+4*i); - } - - FOR(i,16) y[i] = x[i]; - - FOR(i,20) { - FOR(j,4) { - FOR(m,4) t[m] = x[(5*j+4*m)%16]; - t[1] ^= L32(t[0]+t[3], 7); - t[2] ^= L32(t[1]+t[0], 9); - t[3] ^= L32(t[2]+t[1],13); - t[0] ^= L32(t[3]+t[2],18); - FOR(m,4) w[4*j+(j+m)%4] = t[m]; - } - FOR(m,16) x[m] = w[m]; - } - - if (h) { - FOR(i,16) x[i] += y[i]; - FOR(i,4) { - x[5*i] -= ld32(c+4*i); - x[6+i] -= ld32(in+4*i); - } - FOR(i,4) { - st32(out+4*i,x[5*i]); - st32(out+16+4*i,x[6+i]); - } - } else - FOR(i,16) st32(out + 4 * i,x[i] + y[i]); -} - -int crypto_core_salsa20(u8 *out,const u8 *in,const u8 *k,const u8 *c) -{ - core(out,in,k,c,0); - return 0; -} - -int crypto_core_hsalsa20(u8 *out,const u8 *in,const u8 *k,const u8 *c) -{ - core(out,in,k,c,1); - return 0; -} - -static const u8 sigma[16] = "expand 32-byte k"; - -int crypto_stream_salsa20_xor(u8 *c,const u8 *m,u64 b,const u8 *n,const u8 *k) -{ - u8 z[16],x[64]; - u32 u,i; - if (!b) return 0; - FOR(i,16) z[i] = 0; - FOR(i,8) z[i] = n[i]; - while (b >= 64) { - crypto_core_salsa20(x,z,k,sigma); - FOR(i,64) c[i] = (m?m[i]:0) ^ x[i]; - u = 1; - for (i = 8;i < 16;++i) { - u += (u32) z[i]; - z[i] = u; - u >>= 8; - } - b -= 64; - c += 64; - if (m) m += 64; - } - if (b) { - crypto_core_salsa20(x,z,k,sigma); - FOR(i,b) c[i] = (m?m[i]:0) ^ x[i]; - } - return 0; -} - -int crypto_stream_salsa20(u8 *c,u64 d,const u8 *n,const u8 *k) -{ - return crypto_stream_salsa20_xor(c,0,d,n,k); -} - -int crypto_stream(u8 *c,u64 d,const u8 *n,const u8 *k) -{ - u8 s[32]; - crypto_core_hsalsa20(s,n,k,sigma); - return crypto_stream_salsa20(c,d,n+16,s); -} - -int crypto_stream_xor(u8 *c,const u8 *m,u64 d,const u8 *n,const u8 *k) -{ - u8 s[32]; - crypto_core_hsalsa20(s,n,k,sigma); - return crypto_stream_salsa20_xor(c,m,d,n+16,s); -} - -sv add1305(u32 *h,const u32 *c) -{ - u32 j,u = 0; - FOR(j,17) { - u += h[j] + c[j]; - h[j] = u & 255; - u >>= 8; - } -} - -static const u32 minusp[17] = { - 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252 -} ; - -int crypto_onetimeauth(u8 *out,const u8 *m,u64 n,const u8 *k) -{ - u32 s,i,j,u,x[17],r[17],h[17],c[17],g[17]; - - FOR(j,17) r[j]=h[j]=0; - FOR(j,16) r[j]=k[j]; - r[3]&=15; - r[4]&=252; - r[7]&=15; - r[8]&=252; - r[11]&=15; - r[12]&=252; - r[15]&=15; - - while (n > 0) { - FOR(j,17) c[j] = 0; - for (j = 0;(j < 16) && (j < n);++j) c[j] = m[j]; - c[j] = 1; - m += j; n -= j; - add1305(h,c); - FOR(i,17) { - x[i] = 0; - FOR(j,17) x[i] += h[j] * ((j <= i) ? r[i - j] : 320 * r[i + 17 - j]); - } - FOR(i,17) h[i] = x[i]; - u = 0; - FOR(j,16) { - u += h[j]; - h[j] = u & 255; - u >>= 8; - } - u += h[16]; h[16] = u & 3; - u = 5 * (u >> 2); - FOR(j,16) { - u += h[j]; - h[j] = u & 255; - u >>= 8; - } - u += h[16]; h[16] = u; - } - - FOR(j,17) g[j] = h[j]; - add1305(h,minusp); - s = -(h[16] >> 7); - FOR(j,17) h[j] ^= s & (g[j] ^ h[j]); - - FOR(j,16) c[j] = k[j + 16]; - c[16] = 0; - add1305(h,c); - FOR(j,16) out[j] = h[j]; - return 0; -} - -int crypto_onetimeauth_verify(const u8 *h,const u8 *m,u64 n,const u8 *k) -{ - u8 x[16]; - crypto_onetimeauth(x,m,n,k); - return crypto_verify_16(h,x); -} - -int crypto_secretbox(u8 *c,const u8 *m,u64 d,const u8 *n,const u8 *k) -{ - int i; - if (d < 32) return -1; - crypto_stream_xor(c,m,d,n,k); - crypto_onetimeauth(c + 16,c + 32,d - 32,c); - FOR(i,16) c[i] = 0; - return 0; -} - -int crypto_secretbox_open(u8 *m,const u8 *c,u64 d,const u8 *n,const u8 *k) -{ - int i; - u8 x[32]; - if (d < 32) return -1; - crypto_stream(x,32,n,k); - if (crypto_onetimeauth_verify(c + 16,c + 32,d - 32,x) != 0) return -1; - crypto_stream_xor(m,c,d,n,k); - FOR(i,32) m[i] = 0; - return 0; -} - -sv set25519(gf r, const gf a) -{ - int i; - FOR(i,16) r[i]=a[i]; -} - -sv car25519(gf o) -{ - int i; - i64 c; - FOR(i,16) { - o[i]+=(1LL<<16); - c=o[i]>>16; - o[(i+1)*(i<15)]+=c-1+37*(c-1)*(i==15); - o[i]-=c<<16; - } -} - -sv sel25519(gf p,gf q,int b) -{ - i64 t,i,c=~(b-1); - FOR(i,16) { - t= c&(p[i]^q[i]); - p[i]^=t; - q[i]^=t; - } -} - -sv pack25519(u8 *o,const gf n) -{ - int i,j,b; - gf m,t; - FOR(i,16) t[i]=n[i]; - car25519(t); - car25519(t); - car25519(t); - FOR(j,2) { - m[0]=t[0]-0xffed; - for(i=1;i<15;i++) { - m[i]=t[i]-0xffff-((m[i-1]>>16)&1); - m[i-1]&=0xffff; - } - m[15]=t[15]-0x7fff-((m[14]>>16)&1); - b=(m[15]>>16)&1; - m[14]&=0xffff; - sel25519(t,m,1-b); - } - FOR(i,16) { - o[2*i]=t[i]&0xff; - o[2*i+1]=t[i]>>8; - } -} - -static int neq25519(const gf a, const gf b) -{ - u8 c[32],d[32]; - pack25519(c,a); - pack25519(d,b); - return crypto_verify_32(c,d); -} - -static u8 par25519(const gf a) -{ - u8 d[32]; - pack25519(d,a); - return d[0]&1; -} - -sv unpack25519(gf o, const u8 *n) -{ - int i; - FOR(i,16) o[i]=n[2*i]+((i64)n[2*i+1]<<8); - o[15]&=0x7fff; -} - -sv A(gf o,const gf a,const gf b) -{ - int i; - FOR(i,16) o[i]=a[i]+b[i]; -} - -sv Z(gf o,const gf a,const gf b) -{ - int i; - FOR(i,16) o[i]=a[i]-b[i]; -} - -sv M(gf o,const gf a,const gf b) -{ - i64 i,j,t[31]; - FOR(i,31) t[i]=0; - FOR(i,16) FOR(j,16) t[i+j]+=a[i]*b[j]; - FOR(i,15) t[i]+=38*t[i+16]; - FOR(i,16) o[i]=t[i]; - car25519(o); - car25519(o); -} - -sv S(gf o,const gf a) -{ - M(o,a,a); -} - -sv inv25519(gf o,const gf i) -{ - gf c; - int a; - FOR(a,16) c[a]=i[a]; - for(a=253;a>=0;a--) { - S(c,c); - if(a!=2&&a!=4) M(c,c,i); - } - FOR(a,16) o[a]=c[a]; -} - -sv pow2523(gf o,const gf i) -{ - gf c; - int a; - FOR(a,16) c[a]=i[a]; - for(a=250;a>=0;a--) { - S(c,c); - if(a!=1) M(c,c,i); - } - FOR(a,16) o[a]=c[a]; -} - -int crypto_scalarmult(u8 *q,const u8 *n,const u8 *p) -{ - u8 z[32]; - i64 x[80],r,i; - gf a,b,c,d,e,f; - FOR(i,31) z[i]=n[i]; - z[31]=(n[31]&127)|64; - z[0]&=248; - unpack25519(x,p); - FOR(i,16) { - b[i]=x[i]; - d[i]=a[i]=c[i]=0; - } - a[0]=d[0]=1; - for(i=254;i>=0;--i) { - r=(z[i>>3]>>(i&7))&1; - sel25519(a,b,r); - sel25519(c,d,r); - A(e,a,c); - Z(a,a,c); - A(c,b,d); - Z(b,b,d); - S(d,e); - S(f,a); - M(a,c,a); - M(c,b,e); - A(e,a,c); - Z(a,a,c); - S(b,a); - Z(c,d,f); - M(a,c,_121665); - A(a,a,d); - M(c,c,a); - M(a,d,f); - M(d,b,x); - S(b,e); - sel25519(a,b,r); - sel25519(c,d,r); - } - FOR(i,16) { - x[i+16]=a[i]; - x[i+32]=c[i]; - x[i+48]=b[i]; - x[i+64]=d[i]; - } - inv25519(x+32,x+32); - M(x+16,x+16,x+32); - pack25519(q,x+16); - return 0; -} - -int crypto_scalarmult_base(u8 *q,const u8 *n) -{ - return crypto_scalarmult(q,n,_9); -} - -int crypto_box_keypair(u8 *y,u8 *x) -{ - randombytes(x,32); - return crypto_scalarmult_base(y,x); -} - -int crypto_box_beforenm(u8 *k,const u8 *y,const u8 *x) -{ - u8 s[32]; - crypto_scalarmult(s,x,y); - return crypto_core_hsalsa20(k,_0,s,sigma); -} - -int crypto_box_afternm(u8 *c,const u8 *m,u64 d,const u8 *n,const u8 *k) -{ - return crypto_secretbox(c,m,d,n,k); -} - -int crypto_box_open_afternm(u8 *m,const u8 *c,u64 d,const u8 *n,const u8 *k) -{ - return crypto_secretbox_open(m,c,d,n,k); -} - -int crypto_box(u8 *c,const u8 *m,u64 d,const u8 *n,const u8 *y,const u8 *x) -{ - u8 k[32]; - crypto_box_beforenm(k,y,x); - return crypto_box_afternm(c,m,d,n,k); -} - -int crypto_box_open(u8 *m,const u8 *c,u64 d,const u8 *n,const u8 *y,const u8 *x) -{ - u8 k[32]; - crypto_box_beforenm(k,y,x); - return crypto_box_open_afternm(m,c,d,n,k); -} - -static u64 R(u64 x,int c) { return (x >> c) | (x << (64 - c)); } -static u64 Ch(u64 x,u64 y,u64 z) { return (x & y) ^ (~x & z); } -static u64 Maj(u64 x,u64 y,u64 z) { return (x & y) ^ (x & z) ^ (y & z); } -static u64 Sigma0(u64 x) { return R(x,28) ^ R(x,34) ^ R(x,39); } -static u64 Sigma1(u64 x) { return R(x,14) ^ R(x,18) ^ R(x,41); } -static u64 sigma0(u64 x) { return R(x, 1) ^ R(x, 8) ^ (x >> 7); } -static u64 sigma1(u64 x) { return R(x,19) ^ R(x,61) ^ (x >> 6); } - -static const u64 K[80] = -{ - 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, - 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, - 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, - 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, - 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, - 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, - 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, - 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, - 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, - 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL, - 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, - 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL, - 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, - 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, - 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, - 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL, - 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, - 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL, - 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, - 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL -}; - -int crypto_hashblocks(u8 *x,const u8 *m,u64 n) -{ - u64 z[8],b[8],a[8],w[16],t; - int i,j; - - FOR(i,8) z[i] = a[i] = dl64(x + 8 * i); - - while (n >= 128) { - FOR(i,16) w[i] = dl64(m + 8 * i); - - FOR(i,80) { - FOR(j,8) b[j] = a[j]; - t = a[7] + Sigma1(a[4]) + Ch(a[4],a[5],a[6]) + K[i] + w[i%16]; - b[7] = t + Sigma0(a[0]) + Maj(a[0],a[1],a[2]); - b[3] += t; - FOR(j,8) a[(j+1)%8] = b[j]; - if (i%16 == 15) - FOR(j,16) - w[j] += w[(j+9)%16] + sigma0(w[(j+1)%16]) + sigma1(w[(j+14)%16]); - } - - FOR(i,8) { a[i] += z[i]; z[i] = a[i]; } - - m += 128; - n -= 128; - } - - FOR(i,8) ts64(x+8*i,z[i]); - - return n; -} - -static const u8 iv[64] = { - 0x6a,0x09,0xe6,0x67,0xf3,0xbc,0xc9,0x08, - 0xbb,0x67,0xae,0x85,0x84,0xca,0xa7,0x3b, - 0x3c,0x6e,0xf3,0x72,0xfe,0x94,0xf8,0x2b, - 0xa5,0x4f,0xf5,0x3a,0x5f,0x1d,0x36,0xf1, - 0x51,0x0e,0x52,0x7f,0xad,0xe6,0x82,0xd1, - 0x9b,0x05,0x68,0x8c,0x2b,0x3e,0x6c,0x1f, - 0x1f,0x83,0xd9,0xab,0xfb,0x41,0xbd,0x6b, - 0x5b,0xe0,0xcd,0x19,0x13,0x7e,0x21,0x79 -} ; - -int crypto_hash(u8 *out,const u8 *m,u64 n) -{ - u8 h[64],x[256]; - u64 i,b = n; - - FOR(i,64) h[i] = iv[i]; - - crypto_hashblocks(h,m,n); - m += n; - n &= 127; - m -= n; - - FOR(i,256) x[i] = 0; - FOR(i,n) x[i] = m[i]; - x[n] = 128; - - n = 256-128*(n<112); - x[n-9] = b >> 61; - ts64(x+n-8,b<<3); - crypto_hashblocks(h,x,n); - - FOR(i,64) out[i] = h[i]; - - return 0; -} - -sv add(gf p[4],gf q[4]) -{ - gf a,b,c,d,t,e,f,g,h; - - Z(a, p[1], p[0]); - Z(t, q[1], q[0]); - M(a, a, t); - A(b, p[0], p[1]); - A(t, q[0], q[1]); - M(b, b, t); - M(c, p[3], q[3]); - M(c, c, D2); - M(d, p[2], q[2]); - A(d, d, d); - Z(e, b, a); - Z(f, d, c); - A(g, d, c); - A(h, b, a); - - M(p[0], e, f); - M(p[1], h, g); - M(p[2], g, f); - M(p[3], e, h); -} - -sv cswap(gf p[4],gf q[4],u8 b) -{ - int i; - FOR(i,4) - sel25519(p[i],q[i],b); -} - -sv pack(u8 *r,gf p[4]) -{ - gf tx, ty, zi; - inv25519(zi, p[2]); - M(tx, p[0], zi); - M(ty, p[1], zi); - pack25519(r, ty); - r[31] ^= par25519(tx) << 7; -} - -sv scalarmult(gf p[4],gf q[4],const u8 *s) -{ - int i; - set25519(p[0],gf0); - set25519(p[1],gf1); - set25519(p[2],gf1); - set25519(p[3],gf0); - for (i = 255;i >= 0;--i) { - const u8 b = (s[i/8]>>(i&7))&1; - cswap(p,q,b); - add(q,p); - add(p,p); - cswap(p,q,b); - } -} - -sv scalarbase(gf p[4],const u8 *s) -{ - gf q[4]; - set25519(q[0],X); - set25519(q[1],Y); - set25519(q[2],gf1); - M(q[3],X,Y); - scalarmult(p,q,s); -} - -int crypto_sign_keypair(u8 *pk, u8 *sk) -{ - u8 d[64]; - gf p[4]; - int i; - - randombytes(sk, 32); - crypto_hash(d, sk, 32); - d[0] &= 248; - d[31] &= 127; - d[31] |= 64; - - scalarbase(p,d); - pack(pk,p); - - FOR(i,32) sk[32 + i] = pk[i]; - return 0; -} - -static const u64 L[32] = {0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10}; - -sv modL(u8 *r,i64 x[64]) -{ - i64 carry,i,j; - for (i = 63;i >= 32;--i) { - carry = 0; - for (j = i - 32;j < i - 12;++j) { - x[j] += carry - 16 * x[i] * L[j - (i - 32)]; - carry = (x[j] + 128) >> 8; - x[j] -= carry << 8; - } - x[j] += carry; - x[i] = 0; - } - carry = 0; - FOR(j,32) { - x[j] += carry - (x[31] >> 4) * L[j]; - carry = x[j] >> 8; - x[j] &= 255; - } - FOR(j,32) x[j] -= carry * L[j]; - FOR(i,32) { - x[i+1] += x[i] >> 8; - r[i] = x[i] & 255; - } -} - -sv reduce(u8 *r) -{ - i64 x[64],i; - FOR(i,64) x[i] = (u64) r[i]; - FOR(i,64) r[i] = 0; - modL(r,x); -} - -int crypto_sign(u8 *sm,u64 *smlen,const u8 *m,u64 n,const u8 *sk) -{ - u8 d[64],h[64],r[64]; - i64 i,j,x[64]; - gf p[4]; - - crypto_hash(d, sk, 32); - d[0] &= 248; - d[31] &= 127; - d[31] |= 64; - - *smlen = n+64; - FOR(i,n) sm[64 + i] = m[i]; - FOR(i,32) sm[32 + i] = d[32 + i]; - - crypto_hash(r, sm+32, n+32); - reduce(r); - scalarbase(p,r); - pack(sm,p); - - FOR(i,32) sm[i+32] = sk[i+32]; - crypto_hash(h,sm,n + 64); - reduce(h); - - FOR(i,64) x[i] = 0; - FOR(i,32) x[i] = (u64) r[i]; - FOR(i,32) FOR(j,32) x[i+j] += h[i] * (u64) d[j]; - modL(sm + 32,x); - - return 0; -} - -static int unpackneg(gf r[4],const u8 p[32]) -{ - gf t, chk, num, den, den2, den4, den6; - set25519(r[2],gf1); - unpack25519(r[1],p); - S(num,r[1]); - M(den,num,D); - Z(num,num,r[2]); - A(den,r[2],den); - - S(den2,den); - S(den4,den2); - M(den6,den4,den2); - M(t,den6,num); - M(t,t,den); - - pow2523(t,t); - M(t,t,num); - M(t,t,den); - M(t,t,den); - M(r[0],t,den); - - S(chk,r[0]); - M(chk,chk,den); - if (neq25519(chk, num)) M(r[0],r[0],I); - - S(chk,r[0]); - M(chk,chk,den); - if (neq25519(chk, num)) return -1; - - if (par25519(r[0]) == (p[31]>>7)) Z(r[0],gf0,r[0]); - - M(r[3],r[0],r[1]); - return 0; -} - -int crypto_sign_open(u8 *m,u64 *mlen,const u8 *sm,u64 n,const u8 *pk) -{ - int i; - u8 t[32],h[64]; - gf p[4],q[4]; - - *mlen = -1; - if (n < 64) return -1; - - if (unpackneg(q,pk)) return -1; - - FOR(i,n) m[i] = sm[i]; - FOR(i,32) m[i+32] = pk[i]; - crypto_hash(h,m,n); - reduce(h); - scalarmult(p,q,h); - - scalarbase(q,sm + 32); - add(p,q); - pack(t,p); - - n -= 64; - if (crypto_verify_32(sm, t)) { - FOR(i,n) m[i] = 0; - return -1; - } - - FOR(i,n) m[i] = sm[i + 64]; - *mlen = n; - return 0; -} - - -#ifdef ZMQ_HAVE_WINDOWS - -#include -#include - -#define NCP ((HCRYPTPROV) 0) - -HCRYPTPROV hProvider = NCP; - -void randombytes(unsigned char *x,unsigned long long xlen) -{ - unsigned i; - BOOL ret; - - if (hProvider == NCP) { - for (;;) { - ret = CryptAcquireContext(&hProvider, NULL, NULL, - PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT); - if (ret != FALSE) - break; - Sleep (1); - } - } - while (xlen > 0) { - if (xlen < 1048576) - i = (unsigned) xlen; - else - i = 1048576; - - ret = CryptGenRandom(hProvider, i, x); - if (ret == FALSE) { - Sleep(1); - continue; - } - x += i; - xlen -= i; - } -} - -int randombytes_close(void) -{ - int rc = -1; - if ((hProvider != NCP) && (CryptReleaseContext(hProvider, 0) != FALSE)) { - hProvider = NCP; - rc = 0; - } - return rc; -} - -int sodium_init (void) -{ - return 0; -} - -#else - -#include -#include - -#ifdef ZMQ_HAVE_GETRANDOM -#include -#else -#include -#include -#include - -static int fd = -1; -#endif - -void randombytes (unsigned char *x,unsigned long long xlen) -{ - int i; -#ifndef ZMQ_HAVE_GETRANDOM - /* Require that random_open has already been called, to avoid - race conditions. */ - assert (fd != -1); -#endif - while (xlen > 0) { - if (xlen < 1048576) - i = xlen; - else - i = 1048576; - -#ifdef ZMQ_HAVE_GETRANDOM - i = getrandom (x, i, 0); -#else - i = read(fd,x,i); -#endif - if (i < 1) { - sleep (1); - continue; - } - x += i; - xlen -= i; - } -} - -/* Do not call manually! Use random_close from random.hpp */ -int randombytes_close (void) -{ - int rc = -1; -#ifndef ZMQ_HAVE_GETRANDOM - if (fd != -1 && close(fd) == 0) { - fd = -1; - rc = 0; - } -#endif /* ZMQ_HAVE_GETRANDOM */ - return rc; -} - -/* Do not call manually! Use random_open from random.hpp */ -int sodium_init (void) -{ -#ifndef ZMQ_HAVE_GETRANDOM - if (fd == -1) { - for (;;) { - int flags = O_RDONLY; -#ifdef ZMQ_HAVE_O_CLOEXEC - flags |= O_CLOEXEC; -#endif - fd = open ("/dev/urandom", flags); - if (fd != -1) - break; - sleep (1); - } -#if !defined ZMQ_HAVE_O_CLOEXEC && defined FD_CLOEXEC - int rc = fcntl (fd, F_SETFD, FD_CLOEXEC); - assert (rc != -1); -#endif - } -#endif /* ZMQ_HAVE_GETRANDOM */ - return 0; -} - -#endif - -#endif -/* clang-format on */ diff --git a/deps/zmq/src/tweetnacl.h b/deps/zmq/src/tweetnacl.h deleted file mode 100644 index 28fd9c19185..00000000000 --- a/deps/zmq/src/tweetnacl.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (c) 2016-2017 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ - -#ifndef TWEETNACL_H -#define TWEETNACL_H - -#if defined(ZMQ_USE_TWEETNACL) - -#define crypto_box_SECRETKEYBYTES 32 -#define crypto_box_BOXZEROBYTES 16 -#define crypto_box_NONCEBYTES 24 -#define crypto_box_ZEROBYTES 32 -#define crypto_box_PUBLICKEYBYTES 32 -#define crypto_box_BEFORENMBYTES 32 -#define crypto_secretbox_KEYBYTES 32 -#define crypto_secretbox_NONCEBYTES 24 -#define crypto_secretbox_ZEROBYTES 32 -#define crypto_secretbox_BOXZEROBYTES 16 -typedef unsigned char u8; -typedef unsigned long u32; -typedef unsigned long long u64; -typedef long long i64; -typedef i64 gf[16]; - -#ifdef __cplusplus -extern "C" { -#endif -void randombytes (unsigned char *, unsigned long long); -/* Do not call manually! Use random_close from random.hpp */ -int randombytes_close (void); -/* Do not call manually! Use random_open from random.hpp */ -int sodium_init (void); - -int crypto_box_keypair (u8 *y_, u8 *x_); -int crypto_box_afternm ( - u8 *c_, const u8 *m_, u64 d_, const u8 *n_, const u8 *k_); -int crypto_box_open_afternm ( - u8 *m_, const u8 *c_, u64 d_, const u8 *n_, const u8 *k_); -int crypto_box ( - u8 *c_, const u8 *m_, u64 d_, const u8 *n_, const u8 *y_, const u8 *x_); -int crypto_box_open ( - u8 *m_, const u8 *c_, u64 d_, const u8 *n_, const u8 *y_, const u8 *x_); -int crypto_box_beforenm (u8 *k_, const u8 *y_, const u8 *x_); -int crypto_scalarmult_base (u8 *q_, const u8 *n_); -int crypto_secretbox (u8 *c_, const u8 *m_, u64 d_, const u8 *n_, const u8 *k_); -int crypto_secretbox_open ( - u8 *m_, const u8 *c_, u64 d_, const u8 *n_, const u8 *k_); -#ifdef __cplusplus -} -#endif - -#endif - -#endif diff --git a/deps/zmq/src/udp_address.cpp b/deps/zmq/src/udp_address.cpp index 41e4770d157..6a5c604e15a 100644 --- a/deps/zmq/src/udp_address.cpp +++ b/deps/zmq/src/udp_address.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -46,8 +19,7 @@ #endif zmq::udp_address_t::udp_address_t () : - _bind_interface (-1), - _is_multicast (false) + _bind_interface (-1), _is_multicast (false) { _bind_address = ip_addr_t::any (AF_INET); _target_address = ip_addr_t::any (AF_INET); @@ -120,7 +92,7 @@ int zmq::udp_address_t::resolve (const char *name_, bool bind_, bool ipv6_) ip_resolver_options_t resolver_opts; resolver_opts.bindable (bind_) - .allow_dns (!bind_) + .allow_dns (true) .allow_nic_name (bind_) .expect_port (true) .ipv6 (ipv6_); diff --git a/deps/zmq/src/udp_address.hpp b/deps/zmq/src/udp_address.hpp index a2530d8fcd3..7cf1bbbe0fd 100644 --- a/deps/zmq/src/udp_address.hpp +++ b/deps/zmq/src/udp_address.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_UDP_ADDRESS_HPP_INCLUDED__ #define __ZMQ_UDP_ADDRESS_HPP_INCLUDED__ diff --git a/deps/zmq/src/udp_engine.cpp b/deps/zmq/src/udp_engine.cpp index 0f7f58b3e4b..fe0a536a6e5 100644 --- a/deps/zmq/src/udp_engine.cpp +++ b/deps/zmq/src/udp_engine.cpp @@ -1,31 +1,4 @@ -/* -Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - -This file is part of libzmq, the ZeroMQ core engine in C++. - -libzmq is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser General Public License (LGPL) as published -by the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -As a special exception, the Contributors give you permission to link -this library with independent modules to produce an executable, -regardless of the license terms of these independent modules, and to -copy and distribute the resulting executable under terms of your choice, -provided that you also meet, for each linked independent module, the -terms and conditions of the license of that module. An independent -module is a module which is not derived from or based on this library. -If you modify this library, you must extend this exception to your -version of the library. - -libzmq is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" @@ -195,7 +168,7 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_) #endif if (rc != 0) { assert_success_or_recoverable (_fd, rc); - error (connection_error); + error (protocol_error); return; } @@ -368,8 +341,8 @@ void zmq::udp_engine_t::sockaddr_to_msg (zmq::msg_t *msg_, char port[6]; const int port_len = - sprintf (port, "%d", static_cast (ntohs (addr_->sin_port))); - zmq_assert (port_len > 0); + snprintf (port, 6, "%d", static_cast (ntohs (addr_->sin_port))); + zmq_assert (port_len > 0 && port_len < 6); const size_t name_len = strlen (name); const int size = static_cast (name_len) + 1 /* colon */ @@ -575,7 +548,7 @@ void zmq::udp_engine_t::in_event () msg.set_flags (msg_t::more); memcpy (msg.data (), group_buffer, group_size); - // This doesn't fit, just ingore + // This doesn't fit, just ignore if (nbytes - 1 < group_size) return; diff --git a/deps/zmq/src/v1_decoder.cpp b/deps/zmq/src/v1_decoder.cpp index e988ed72ee9..59a481671b8 100644 --- a/deps/zmq/src/v1_decoder.cpp +++ b/deps/zmq/src/v1_decoder.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -40,8 +13,7 @@ #include "err.hpp" zmq::v1_decoder_t::v1_decoder_t (size_t bufsize_, int64_t maxmsgsize_) : - decoder_base_t (bufsize_), - _max_msg_size (maxmsgsize_) + decoder_base_t (bufsize_), _max_msg_size (maxmsgsize_) { int rc = _in_progress.init (); errno_assert (rc == 0); diff --git a/deps/zmq/src/v1_decoder.hpp b/deps/zmq/src/v1_decoder.hpp index ccf63fc0475..56a0e30a36f 100644 --- a/deps/zmq/src/v1_decoder.hpp +++ b/deps/zmq/src/v1_decoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_V1_DECODER_HPP_INCLUDED__ #define __ZMQ_V1_DECODER_HPP_INCLUDED__ diff --git a/deps/zmq/src/v1_encoder.cpp b/deps/zmq/src/v1_encoder.cpp index 38e7e982fb8..715da11e6fb 100644 --- a/deps/zmq/src/v1_encoder.cpp +++ b/deps/zmq/src/v1_encoder.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "encoder.hpp" diff --git a/deps/zmq/src/v1_encoder.hpp b/deps/zmq/src/v1_encoder.hpp index 3f7a57e3330..4a3f920227f 100644 --- a/deps/zmq/src/v1_encoder.hpp +++ b/deps/zmq/src/v1_encoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_V1_ENCODER_HPP_INCLUDED__ #define __ZMQ_V1_ENCODER_HPP_INCLUDED__ diff --git a/deps/zmq/src/v2_decoder.cpp b/deps/zmq/src/v2_decoder.cpp index 5848d6a0f82..6cdda4c1d8e 100644 --- a/deps/zmq/src/v2_decoder.cpp +++ b/deps/zmq/src/v2_decoder.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include diff --git a/deps/zmq/src/v2_decoder.hpp b/deps/zmq/src/v2_decoder.hpp index 4c5d135d3d3..93bba53ea73 100644 --- a/deps/zmq/src/v2_decoder.hpp +++ b/deps/zmq/src/v2_decoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_V2_DECODER_HPP_INCLUDED__ #define __ZMQ_V2_DECODER_HPP_INCLUDED__ diff --git a/deps/zmq/src/v2_encoder.cpp b/deps/zmq/src/v2_encoder.cpp index f331adee72a..a4ce0eb933e 100644 --- a/deps/zmq/src/v2_encoder.cpp +++ b/deps/zmq/src/v2_encoder.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "v2_protocol.hpp" diff --git a/deps/zmq/src/v2_encoder.hpp b/deps/zmq/src/v2_encoder.hpp index 4f60616f493..586ed917c0e 100644 --- a/deps/zmq/src/v2_encoder.hpp +++ b/deps/zmq/src/v2_encoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_V2_ENCODER_HPP_INCLUDED__ #define __ZMQ_V2_ENCODER_HPP_INCLUDED__ diff --git a/deps/zmq/src/v2_protocol.hpp b/deps/zmq/src/v2_protocol.hpp index f1297295bc8..2b4164d07d5 100644 --- a/deps/zmq/src/v2_protocol.hpp +++ b/deps/zmq/src/v2_protocol.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_V2_PROTOCOL_HPP_INCLUDED__ #define __ZMQ_V2_PROTOCOL_HPP_INCLUDED__ diff --git a/deps/zmq/src/v3_1_encoder.cpp b/deps/zmq/src/v3_1_encoder.cpp index f9e11dfaff5..f6b04c3549b 100644 --- a/deps/zmq/src/v3_1_encoder.cpp +++ b/deps/zmq/src/v3_1_encoder.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2020 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "v2_protocol.hpp" @@ -56,8 +29,6 @@ void zmq::v3_1_encoder_t::message_ready () protocol_flags = 0; if (in_progress ()->flags () & msg_t::more) protocol_flags |= v2_protocol_t::more_flag; - if (in_progress ()->size () > UCHAR_MAX) - protocol_flags |= v2_protocol_t::large_flag; if (in_progress ()->flags () & msg_t::command || in_progress ()->is_subscribe () || in_progress ()->is_cancel ()) { protocol_flags |= v2_protocol_t::command_flag; @@ -66,6 +37,10 @@ void zmq::v3_1_encoder_t::message_ready () else if (in_progress ()->is_cancel ()) size += zmq::msg_t::cancel_cmd_name_size; } + // Calculate large_flag after command_flag. Subscribe or cancel commands + // increase the message size. + if (size > UCHAR_MAX) + protocol_flags |= v2_protocol_t::large_flag; // Encode the message length. For messages less then 256 bytes, // the length is encoded as 8-bit unsigned integer. For larger diff --git a/deps/zmq/src/v3_1_encoder.hpp b/deps/zmq/src/v3_1_encoder.hpp index d5d9c136698..4b56ef8bda8 100644 --- a/deps/zmq/src/v3_1_encoder.hpp +++ b/deps/zmq/src/v3_1_encoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2020 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_V3_1_ENCODER_HPP_INCLUDED__ #define __ZMQ_V3_1_ENCODER_HPP_INCLUDED__ diff --git a/deps/zmq/src/version.rc.in b/deps/zmq/src/version.rc.in index e2a73466b0f..34280555b9a 100644 --- a/deps/zmq/src/version.rc.in +++ b/deps/zmq/src/version.rc.in @@ -1,93 +1,93 @@ -///////////////////////////////////////////////////////////////////////////// -// -// VERSIONINFO resource -// -// http://msdn.microsoft.com/en-us/library/windows/desktop/aa381058(v=vs.85).aspx - -// @MAJOR@,@MINOR@,@BUILD@,@PATCH@ -#define VER_FILEVERSION @ZMQ_VERSION_MAJOR@,@ZMQ_VERSION_MINOR@,@ZMQ_VERSION_PATCH@,0 -#define VER_FILEVERSION_STR "@ZMQ_VERSION_MAJOR@.@ZMQ_VERSION_MINOR@.@ZMQ_VERSION_PATCH@.0\0" - -#define VER_PRODUCTVERSION VER_FILEVERSION -#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR - - -// versionID -// Version-information resource identifier. This value must be 1. -1 VERSIONINFO - -//// fixed-info -// Binary version number for the file. - FILEVERSION VER_FILEVERSION - -// Binary version number for the product with which the file is distributed. - PRODUCTVERSION VER_PRODUCTVERSION - -// Bits in the FILEFLAGS statement are valid. - FILEFLAGSMASK 0x17L - -// Attributes of the file. -// VS_FF_DEBUG = 1 : File contains debugging information or is compiled with debugging features enabled. -// VS_FF_PATCHED = 4 : File has been modified and is not identical to the original shipping file of the -// same version number. -// VS_FF_PRERELEASE = 2 : File is a development version, not a commercially released product. -// VS_FF_PRIVATEBUILD = 8 : File was not built using standard release procedures. -// VS_FF_SPECIALBUILD = 20 : File was built by the original company using standard release procedures but is a -// : variation of the standard file of the same version number. -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x2L -#endif - -// Operating system for which this file was designed. -// VOS_DOS = 0x10000 : File was designed for MS-DOS. -// VOS_NT = 0x40000 : File was designed for 32-bit Windows. -// VOS_WINDOWS16 = 0x1 : File was designed for 16-bit Windows. -// VOS_WINDOWS32 = 0x4 : File was designed for 32-bit Windows. -// VOS_DOS_WINDOWS16 = 0x10001 : File was designed for 16-bit Windows running with MS-DOS. -// VOS_DOS_WINDOWS32 = 0x10004 : File was designed for 32-bit Windows running with MS-DOS. -// VOS_NT_WINDOWS32 = 0x40004 : File was designed for 32-bit Windows. -// NB: appears obsolete, nothing for x64. - FILEOS 0x4L - -// General type of file. -// VFT_APP = 0x1 : File contains an application. -// VFT_DLL = 0x2 : File contains a dynamic-link library (DLL). -// VFT_DRV = 0x3 : File contains a device driver. -// VFT_FONT = 0x4 : File contains a font. -// VFT_VXD = 0x5 : File contains a virtual device. -// VFT_STATIC_LIB = 0x7 : File contains a static-link library. - FILETYPE 0x2L - -// Function of the file. - FILESUBTYPE 0x0L - -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904b0" - BEGIN - VALUE "CompanyName", "iMatix Corporation" - VALUE "FileDescription", "ZeroMQ lightweight messaging kernel" - VALUE "FileVersion", VER_FILEVERSION_STR - VALUE "InternalName", "zeromq" - VALUE "LegalCopyright", "Copyright (c) 2012 The ZeroMQ Authors." - VALUE "OriginalFilename", "libzmq.dll" - VALUE "ProductName", "ZeroMQ" - VALUE "ProductVersion", VER_PRODUCTVERSION_STR - END - END - - BLOCK "VarFileInfo" - BEGIN -// langID, one of the following language codes. -// 0x409 : U.S. English -// 0x809 : U.K. English -// charsetID, one of the following character-set identifiers. -// 1200 : Unicode - VALUE "Translation", 0x809, 1200 - END -END - -// end of file. +///////////////////////////////////////////////////////////////////////////// +// +// VERSIONINFO resource +// +// http://msdn.microsoft.com/en-us/library/windows/desktop/aa381058(v=vs.85).aspx + +// @MAJOR@,@MINOR@,@BUILD@,@PATCH@ +#define VER_FILEVERSION @ZMQ_VERSION_MAJOR@,@ZMQ_VERSION_MINOR@,@ZMQ_VERSION_PATCH@,0 +#define VER_FILEVERSION_STR "@ZMQ_VERSION_MAJOR@.@ZMQ_VERSION_MINOR@.@ZMQ_VERSION_PATCH@.0\0" + +#define VER_PRODUCTVERSION VER_FILEVERSION +#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR + + +// versionID +// Version-information resource identifier. This value must be 1. +1 VERSIONINFO + +//// fixed-info +// Binary version number for the file. + FILEVERSION VER_FILEVERSION + +// Binary version number for the product with which the file is distributed. + PRODUCTVERSION VER_PRODUCTVERSION + +// Bits in the FILEFLAGS statement are valid. + FILEFLAGSMASK 0x17L + +// Attributes of the file. +// VS_FF_DEBUG = 1 : File contains debugging information or is compiled with debugging features enabled. +// VS_FF_PATCHED = 4 : File has been modified and is not identical to the original shipping file of the +// same version number. +// VS_FF_PRERELEASE = 2 : File is a development version, not a commercially released product. +// VS_FF_PRIVATEBUILD = 8 : File was not built using standard release procedures. +// VS_FF_SPECIALBUILD = 20 : File was built by the original company using standard release procedures but is a +// : variation of the standard file of the same version number. +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x2L +#endif + +// Operating system for which this file was designed. +// VOS_DOS = 0x10000 : File was designed for MS-DOS. +// VOS_NT = 0x40000 : File was designed for 32-bit Windows. +// VOS_WINDOWS16 = 0x1 : File was designed for 16-bit Windows. +// VOS_WINDOWS32 = 0x4 : File was designed for 32-bit Windows. +// VOS_DOS_WINDOWS16 = 0x10001 : File was designed for 16-bit Windows running with MS-DOS. +// VOS_DOS_WINDOWS32 = 0x10004 : File was designed for 32-bit Windows running with MS-DOS. +// VOS_NT_WINDOWS32 = 0x40004 : File was designed for 32-bit Windows. +// NB: appears obsolete, nothing for x64. + FILEOS 0x4L + +// General type of file. +// VFT_APP = 0x1 : File contains an application. +// VFT_DLL = 0x2 : File contains a dynamic-link library (DLL). +// VFT_DRV = 0x3 : File contains a device driver. +// VFT_FONT = 0x4 : File contains a font. +// VFT_VXD = 0x5 : File contains a virtual device. +// VFT_STATIC_LIB = 0x7 : File contains a static-link library. + FILETYPE 0x2L + +// Function of the file. + FILESUBTYPE 0x0L + +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904b0" + BEGIN + VALUE "CompanyName", "iMatix Corporation" + VALUE "FileDescription", "ZeroMQ lightweight messaging kernel" + VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "InternalName", "zeromq" + VALUE "LegalCopyright", "Copyright (c) 2012 The ZeroMQ Authors." + VALUE "OriginalFilename", "libzmq.dll" + VALUE "ProductName", "ZeroMQ" + VALUE "ProductVersion", VER_PRODUCTVERSION_STR + END + END + + BLOCK "VarFileInfo" + BEGIN +// langID, one of the following language codes. +// 0x409 : U.S. English +// 0x809 : U.K. English +// charsetID, one of the following character-set identifiers. +// 1200 : Unicode + VALUE "Translation", 0x809, 1200 + END +END + +// end of file. diff --git a/deps/zmq/src/vmci.cpp b/deps/zmq/src/vmci.cpp index 4edd096bec0..48c10290d99 100644 --- a/deps/zmq/src/vmci.cpp +++ b/deps/zmq/src/vmci.cpp @@ -1,34 +1,9 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" +#include "ip.hpp" #include "vmci.hpp" +#include "vmci_address.hpp" #if defined ZMQ_HAVE_VMCI @@ -97,4 +72,23 @@ void zmq::tune_vmci_connect_timeout (ctx_t *context_, #endif } +zmq::fd_t zmq::vmci_open_socket (const char *address_, + const zmq::options_t &options_, + zmq::vmci_address_t *out_vmci_addr_) +{ + // Convert the textual address into address structure. + int rc = out_vmci_addr_->resolve (address_); + if (rc != 0) + return retired_fd; + + // Create the socket. + fd_t s = open_socket (out_vmci_addr_->family (), SOCK_STREAM, 0); + + if (s == retired_fd) { + return retired_fd; + } + + return s; +} + #endif diff --git a/deps/zmq/src/vmci.hpp b/deps/zmq/src/vmci.hpp index 16a0c7346a5..983cf72dd35 100644 --- a/deps/zmq/src/vmci.hpp +++ b/deps/zmq/src/vmci.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_VMCI_HPP_INCLUDED__ #define __ZMQ_VMCI_HPP_INCLUDED__ @@ -59,6 +32,10 @@ void tune_vmci_connect_timeout (ctx_t *context_, fd_t sockfd_, struct timeval timeout_); #endif + +fd_t vmci_open_socket (const char *address_, + const options_t &options_, + vmci_address_t *out_vmci_addr_); } #endif diff --git a/deps/zmq/src/vmci_address.cpp b/deps/zmq/src/vmci_address.cpp index cf97d99cbdc..83fbb920fe1 100644 --- a/deps/zmq/src/vmci_address.cpp +++ b/deps/zmq/src/vmci_address.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" @@ -39,6 +12,11 @@ #include "err.hpp" +zmq::vmci_address_t::vmci_address_t () +{ + memset (&address, 0, sizeof address); +} + zmq::vmci_address_t::vmci_address_t (ctx_t *parent_) : parent (parent_) { memset (&address, 0, sizeof address); @@ -56,10 +34,6 @@ zmq::vmci_address_t::vmci_address_t (const sockaddr *sa, memcpy (&address, sa, sa_len); } -zmq::vmci_address_t::~vmci_address_t () -{ -} - int zmq::vmci_address_t::resolve (const char *path_) { // Find the ':' at end that separates address from the port number. @@ -125,7 +99,7 @@ int zmq::vmci_address_t::resolve (const char *path_) return 0; } -int zmq::vmci_address_t::to_string (std::string &addr_) +int zmq::vmci_address_t::to_string (std::string &addr_) const { if (address.svm_family != parent->get_vmci_socket_family ()) { addr_.clear (); @@ -164,4 +138,13 @@ socklen_t zmq::vmci_address_t::addrlen () const return static_cast (sizeof address); } +#if defined ZMQ_HAVE_WINDOWS +unsigned short zmq::vmci_address_t::family () const +#else +sa_family_t zmq::vmci_address_t::family () const +#endif +{ + return parent->get_vmci_socket_family (); +} + #endif diff --git a/deps/zmq/src/vmci_address.hpp b/deps/zmq/src/vmci_address.hpp index 16dab4a3820..e8f19236fdf 100644 --- a/deps/zmq/src/vmci_address.hpp +++ b/deps/zmq/src/vmci_address.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_VMCI_ADDRESS_HPP_INCLUDED__ #define __ZMQ_VMCI_ADDRESS_HPP_INCLUDED__ @@ -43,16 +16,21 @@ namespace zmq class vmci_address_t { public: + vmci_address_t (); vmci_address_t (ctx_t *parent_); vmci_address_t (const sockaddr *sa, socklen_t sa_len, ctx_t *parent_); - ~vmci_address_t (); // This function sets up the address for VMCI transport. int resolve (const char *path_); // The opposite to resolve() - int to_string (std::string &addr_); + int to_string (std::string &addr_) const; +#if defined ZMQ_HAVE_WINDOWS + unsigned short family () const; +#else + sa_family_t family () const; +#endif const sockaddr *addr () const; socklen_t addrlen () const; @@ -60,8 +38,6 @@ class vmci_address_t struct sockaddr_vm address; ctx_t *parent; - vmci_address_t (); - ZMQ_NON_COPYABLE_NOR_MOVABLE (vmci_address_t) }; } diff --git a/deps/zmq/src/vmci_connecter.cpp b/deps/zmq/src/vmci_connecter.cpp index 5768c78ef52..19491686fb1 100644 --- a/deps/zmq/src/vmci_connecter.cpp +++ b/deps/zmq/src/vmci_connecter.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" @@ -35,69 +8,41 @@ #include -#include "stream_engine.hpp" #include "io_thread.hpp" #include "platform.hpp" #include "random.hpp" #include "err.hpp" #include "ip.hpp" #include "address.hpp" -#include "session_base.hpp" #include "vmci_address.hpp" #include "vmci.hpp" +#include "session_base.hpp" zmq::vmci_connecter_t::vmci_connecter_t (class io_thread_t *io_thread_, class session_base_t *session_, const options_t &options_, - const address_t *addr_, + address_t *addr_, bool delayed_start_) : - own_t (io_thread_, options_), - io_object_t (io_thread_), - addr (addr_), - s (retired_fd), - handle_valid (false), - delayed_start (delayed_start_), - timer_started (false), - session (session_), - current_reconnect_ivl (options.reconnect_ivl) + stream_connecter_base_t ( + io_thread_, session_, options_, addr_, delayed_start_), + _connect_timer_started (false) { - zmq_assert (addr); - zmq_assert (addr->protocol == "vmci"); - addr->to_string (endpoint); - socket = session->get_socket (); + zmq_assert (_addr->protocol == protocol_name::vmci); } zmq::vmci_connecter_t::~vmci_connecter_t () { - zmq_assert (!timer_started); - zmq_assert (!handle_valid); - zmq_assert (s == retired_fd); -} - -void zmq::vmci_connecter_t::process_plug () -{ - if (delayed_start) - add_reconnect_timer (); - else - start_connecting (); + zmq_assert (!_connect_timer_started); } void zmq::vmci_connecter_t::process_term (int linger_) { - if (timer_started) { - cancel_timer (reconnect_timer_id); - timer_started = false; + if (_connect_timer_started) { + cancel_timer (connect_timer_id); + _connect_timer_started = false; } - if (handle_valid) { - rm_fd (handle); - handle_valid = false; - } - - if (s != retired_fd) - close (); - - own_t::process_term (linger_); + stream_connecter_base_t::process_term (linger_); } void zmq::vmci_connecter_t::in_event () @@ -110,9 +55,26 @@ void zmq::vmci_connecter_t::in_event () void zmq::vmci_connecter_t::out_event () { - fd_t fd = connect (); - rm_fd (handle); - handle_valid = false; + if (_connect_timer_started) { + cancel_timer (connect_timer_id); + _connect_timer_started = false; + } + + // TODO this is still very similar to (t)ipc_connecter_t, maybe the + // differences can be factored out + + rm_handle (); + + const fd_t fd = connect (); + + if (fd == retired_fd + && ((options.reconnect_stop & ZMQ_RECONNECT_STOP_CONN_REFUSED) + && errno == ECONNREFUSED)) { + send_conn_failed (_session); + close (); + terminate (); + return; + } // Handle the error condition by attempt to reconnect. if (fd == retired_fd) { @@ -135,148 +97,154 @@ void zmq::vmci_connecter_t::out_event () #endif } - // Create the engine object for this connection. - stream_engine_t *engine = new (std::nothrow) stream_engine_t ( - fd, options, make_unconnected_bind_endpoint_pair (endpoint)); - alloc_assert (engine); - - // Attach the engine to the corresponding session object. - send_attach (session, engine); + create_engine ( + fd, zmq::vmci_connecter_t::get_socket_name (fd, socket_end_local)); +} - // Shut the connecter down. - terminate (); +std::string +zmq::vmci_connecter_t::get_socket_name (zmq::fd_t fd_, + socket_end_t socket_end_) const +{ + struct sockaddr_storage ss; + const zmq_socklen_t sl = get_socket_address (fd_, socket_end_, &ss); + if (sl == 0) { + return std::string (); + } - socket->event_connected (make_unconnected_bind_endpoint_pair (endpoint), - fd); + const vmci_address_t addr (reinterpret_cast (&ss), sl, + this->get_ctx ()); + std::string address_string; + addr.to_string (address_string); + return address_string; } void zmq::vmci_connecter_t::timer_event (int id_) { - zmq_assert (id_ == reconnect_timer_id); - timer_started = false; - start_connecting (); + if (id_ == connect_timer_id) { + _connect_timer_started = false; + rm_handle (); + close (); + add_reconnect_timer (); + } else + stream_connecter_base_t::timer_event (id_); } void zmq::vmci_connecter_t::start_connecting () { // Open the connecting socket. - int rc = open (); + const int rc = open (); // Connect may succeed in synchronous manner. if (rc == 0) { - handle = add_fd (s); - handle_valid = true; + _handle = add_fd (_s); out_event (); } + // Connection establishment may be delayed. Poll for its completion. + else if (rc == -1 && errno == EINPROGRESS) { + _handle = add_fd (_s); + set_pollout (_handle); + _socket->event_connect_delayed ( + make_unconnected_connect_endpoint_pair (_endpoint), zmq_errno ()); + + // add userspace connect timeout + add_connect_timer (); + } + // Handle any other error condition by eventual reconnect. else { - if (s != retired_fd) + if (_s != retired_fd) close (); add_reconnect_timer (); } } -void zmq::vmci_connecter_t::add_reconnect_timer () +void zmq::vmci_connecter_t::add_connect_timer () { - if (options.reconnect_ivl > 0) { - int rc_ivl = get_new_reconnect_ivl (); - add_timer (rc_ivl, reconnect_timer_id); - socket->event_connect_retried ( - make_unconnected_bind_endpoint_pair (endpoint), rc_ivl); - timer_started = true; + if (options.connect_timeout > 0) { + add_timer (options.connect_timeout, connect_timer_id); + _connect_timer_started = true; } } -int zmq::vmci_connecter_t::get_new_reconnect_ivl () -{ - // The new interval is the current interval + random value. - int this_interval = - current_reconnect_ivl + (generate_random () % options.reconnect_ivl); - - // Only change the current reconnect interval if the maximum reconnect - // interval was set and if it's larger than the reconnect interval. - if (options.reconnect_ivl_max > 0 - && options.reconnect_ivl_max > options.reconnect_ivl) { - // Calculate the next interval - current_reconnect_ivl = current_reconnect_ivl * 2; - if (current_reconnect_ivl >= options.reconnect_ivl_max) { - current_reconnect_ivl = options.reconnect_ivl_max; - } - } - return this_interval; -} - int zmq::vmci_connecter_t::open () { - zmq_assert (s == retired_fd); + zmq_assert (_s == retired_fd); - int family = this->get_ctx ()->get_vmci_socket_family (); - if (family == -1) - return -1; + // Resolve the address + if (_addr->resolved.vmci_addr != NULL) { + LIBZMQ_DELETE (_addr->resolved.vmci_addr); + } - // Create the socket. - s = open_socket (family, SOCK_STREAM, 0); -#ifdef ZMQ_HAVE_WINDOWS - if (s == INVALID_SOCKET) { - errno = wsa_error_to_errno (WSAGetLastError ()); + _addr->resolved.vmci_addr = + new (std::nothrow) vmci_address_t (this->get_ctx ()); + alloc_assert (_addr->resolved.vmci_addr); + _s = vmci_open_socket (_addr->address.c_str (), options, + _addr->resolved.vmci_addr); + if (_s == retired_fd) { + // TODO we should emit some event in this case! + + LIBZMQ_DELETE (_addr->resolved.vmci_addr); return -1; } -#else - if (s == -1) - return -1; -#endif + zmq_assert (_addr->resolved.vmci_addr != NULL); - // Connect to the remote peer. - int rc = ::connect (s, addr->resolved.vmci_addr->addr (), - addr->resolved.vmci_addr->addrlen ()); + // Set the socket to non-blocking mode so that we get async connect(). + unblock_socket (_s); + + const vmci_address_t *const vmci_addr = _addr->resolved.vmci_addr; + int rc; + + // Connect to the remote peer. +#if defined ZMQ_HAVE_VXWORKS + rc = ::connect (_s, (sockaddr *) vmci_addr->addr (), vmci_addr->addrlen ()); +#else + rc = ::connect (_s, vmci_addr->addr (), vmci_addr->addrlen ()); +#endif // Connect was successful immediately. - if (rc == 0) + if (rc == 0) { return 0; + } - // Forward the error. - return -1; -} - -void zmq::vmci_connecter_t::close () -{ - zmq_assert (s != retired_fd); + // Translate error codes indicating asynchronous connect has been + // launched to a uniform EINPROGRESS. #ifdef ZMQ_HAVE_WINDOWS - const int rc = closesocket (s); - wsa_assert (rc != SOCKET_ERROR); + const int last_error = WSAGetLastError (); + if (last_error == WSAEINPROGRESS || last_error == WSAEWOULDBLOCK) + errno = EINPROGRESS; + else + errno = wsa_error_to_errno (last_error); #else - const int rc = ::close (s); - errno_assert (rc == 0); + if (errno == EINTR) + errno = EINPROGRESS; #endif - socket->event_closed (make_unconnected_bind_endpoint_pair (endpoint), s); - s = retired_fd; + return -1; } zmq::fd_t zmq::vmci_connecter_t::connect () { - // Following code should handle both Berkeley-derived socket - // implementations and Solaris. + // Async connect has finished. Check whether an error occurred int err = 0; -#if defined ZMQ_HAVE_HPUX - int len = sizeof (err); +#if defined ZMQ_HAVE_HPUX || defined ZMQ_HAVE_VXWORKS + int len = sizeof err; #else - socklen_t len = sizeof (err); + socklen_t len = sizeof err; #endif - int rc = getsockopt (s, SOL_SOCKET, SO_ERROR, (char *) &err, &len); + + const int rc = getsockopt (_s, SOL_SOCKET, SO_ERROR, + reinterpret_cast (&err), &len); // Assert if the error was caused by 0MQ bug. // Networking problems are OK. No need to assert. #ifdef ZMQ_HAVE_WINDOWS zmq_assert (rc == 0); if (err != 0) { - if (err != WSAECONNREFUSED && err != WSAETIMEDOUT - && err != WSAECONNABORTED && err != WSAEHOSTUNREACH - && err != WSAENETUNREACH && err != WSAENETDOWN && err != WSAEACCES - && err != WSAEINVAL && err != WSAEADDRINUSE - && err != WSAECONNRESET) { + if (err == WSAEBADF || err == WSAENOPROTOOPT || err == WSAENOTSOCK + || err == WSAENOBUFS) { wsa_assert_no (err); } + errno = wsa_error_to_errno (err); return retired_fd; } #else @@ -286,16 +254,20 @@ zmq::fd_t zmq::vmci_connecter_t::connect () err = errno; if (err != 0) { errno = err; - errno_assert (errno == ECONNREFUSED || errno == ECONNRESET - || errno == ETIMEDOUT || errno == EHOSTUNREACH - || errno == ENETUNREACH || errno == ENETDOWN - || errno == EINVAL); +#if !defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE + errno_assert (errno != EBADF && errno != ENOPROTOOPT + && errno != ENOTSOCK && errno != ENOBUFS); +#else + errno_assert (errno != ENOPROTOOPT && errno != ENOTSOCK + && errno != ENOBUFS); +#endif return retired_fd; } #endif - fd_t result = s; - s = retired_fd; + // Return the newly connected socket. + const fd_t result = _s; + _s = retired_fd; return result; } diff --git a/deps/zmq/src/vmci_connecter.hpp b/deps/zmq/src/vmci_connecter.hpp index d0ebaac99a9..c5ebc90dcbb 100644 --- a/deps/zmq/src/vmci_connecter.hpp +++ b/deps/zmq/src/vmci_connecter.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_VMCI_CONNECTER_HPP_INCLUDED__ #define __ZMQ_VMCI_CONNECTER_HPP_INCLUDED__ @@ -38,6 +11,7 @@ #include "own.hpp" #include "stdint.hpp" #include "io_object.hpp" +#include "stream_connecter_base.hpp" namespace zmq { @@ -45,8 +19,7 @@ class io_thread_t; class session_base_t; struct address_t; -// TODO consider refactoring this to derive from stream_connecter_base_t -class vmci_connecter_t ZMQ_FINAL : public own_t, public io_object_t +class vmci_connecter_t ZMQ_FINAL : public stream_connecter_base_t { public: // If 'delayed_start' is true connecter first waits for a while, @@ -54,19 +27,21 @@ class vmci_connecter_t ZMQ_FINAL : public own_t, public io_object_t vmci_connecter_t (zmq::io_thread_t *io_thread_, zmq::session_base_t *session_, const options_t &options_, - const address_t *addr_, + address_t *addr_, bool delayed_start_); ~vmci_connecter_t (); + protected: + std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const; + private: - // ID of the timer used to delay the reconnection. + // ID of the timer used to check the connect timeout, must be different from stream_connecter_base_t::reconnect_timer_id. enum { - reconnect_timer_id = 1 + connect_timer_id = 2 }; // Handlers for incoming commands. - void process_plug (); void process_term (int linger_); // Handlers for I/O events. @@ -77,8 +52,8 @@ class vmci_connecter_t ZMQ_FINAL : public own_t, public io_object_t // Internal function to start the actual connection establishment. void start_connecting (); - // Internal function to add a reconnect timer - void add_reconnect_timer (); + // Internal function to add a connect timer + void add_connect_timer (); // Internal function to return a reconnect backoff delay. // Will modify the current_reconnect_ivl used for next call @@ -90,43 +65,12 @@ class vmci_connecter_t ZMQ_FINAL : public own_t, public io_object_t // EAGAIN errno if async connect was launched. int open (); - // Close the connecting socket. - void close (); - // Get the file descriptor of newly created connection. Returns // retired_fd if the connection was unsuccessful. fd_t connect (); - // Address to connect to. Owned by session_base_t. - const address_t *addr; - - // Underlying socket. - fd_t s; - - // Handle corresponding to the listening socket. - handle_t handle; - - // If true file descriptor is registered with the poller and 'handle' - // contains valid value. - bool handle_valid; - - // If true, connecter is waiting a while before trying to connect. - const bool delayed_start; - // True iff a timer has been started. - bool timer_started; - - // Reference to the session we belong to. - zmq::session_base_t *session; - - // Current reconnect ivl, updated for backoff strategy - int current_reconnect_ivl; - - // String representation of endpoint to connect to - std::string endpoint; - - // Socket - zmq::socket_base_t *socket; + bool _connect_timer_started; ZMQ_NON_COPYABLE_NOR_MOVABLE (vmci_connecter_t) }; diff --git a/deps/zmq/src/vmci_listener.cpp b/deps/zmq/src/vmci_listener.cpp index 0ac6db3410e..af7d3602b33 100644 --- a/deps/zmq/src/vmci_listener.cpp +++ b/deps/zmq/src/vmci_listener.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" @@ -35,7 +8,7 @@ #include -#include "stream_engine.hpp" +//#include "stream_engine.hpp" #include "vmci_address.hpp" #include "io_thread.hpp" #include "session_base.hpp" @@ -55,40 +28,18 @@ zmq::vmci_listener_t::vmci_listener_t (io_thread_t *io_thread_, socket_base_t *socket_, const options_t &options_) : - own_t (io_thread_, options_), - io_object_t (io_thread_), - s (retired_fd), - socket (socket_) + stream_listener_base_t (io_thread_, socket_, options_) { } -zmq::vmci_listener_t::~vmci_listener_t () -{ - zmq_assert (s == retired_fd); -} - -void zmq::vmci_listener_t::process_plug () -{ - // Start polling for incoming connections. - handle = add_fd (s); - set_pollin (handle); -} - -void zmq::vmci_listener_t::process_term (int linger_) -{ - rm_fd (handle); - close (); - own_t::process_term (linger_); -} - void zmq::vmci_listener_t::in_event () { fd_t fd = accept (); // If connection was reset by the peer in the meantime, just ignore it. if (fd == retired_fd) { - socket->event_accept_failed ( - make_unconnected_bind_endpoint_pair (endpoint), zmq_errno ()); + _socket->event_accept_failed ( + make_unconnected_bind_endpoint_pair (_endpoint), zmq_errno ()); return; } @@ -107,41 +58,24 @@ void zmq::vmci_listener_t::in_event () } // Create the engine object for this connection. - stream_engine_t *engine = new (std::nothrow) stream_engine_t ( - fd, options, make_unconnected_bind_endpoint_pair (endpoint)); - alloc_assert (engine); - - // Choose I/O thread to run connecter in. Given that we are already - // running in an I/O thread, there must be at least one available. - io_thread_t *io_thread = choose_io_thread (options.affinity); - zmq_assert (io_thread); - - // Create and launch a session object. - session_base_t *session = - session_base_t::create (io_thread, false, socket, options, NULL); - errno_assert (session); - session->inc_seqnum (); - launch_child (session); - send_attach (session, engine, false); - socket->event_accepted (make_unconnected_bind_endpoint_pair (endpoint), fd); + create_engine (fd); } -int zmq::vmci_listener_t::get_local_address (std::string &addr_) +std::string +zmq::vmci_listener_t::get_socket_name (zmq::fd_t fd_, + socket_end_t socket_end_) const { struct sockaddr_storage ss; -#ifdef ZMQ_HAVE_HPUX - int sl = sizeof (ss); -#else - socklen_t sl = sizeof (ss); -#endif - int rc = getsockname (s, (sockaddr *) &ss, &sl); - if (rc != 0) { - addr_.clear (); - return rc; + const zmq_socklen_t sl = get_socket_address (fd_, socket_end_, &ss); + if (sl == 0) { + return std::string (); } - vmci_address_t addr ((struct sockaddr *) &ss, sl, this->get_ctx ()); - return addr.to_string (addr_); + const vmci_address_t addr (reinterpret_cast (&ss), sl, + this->get_ctx ()); + std::string address_string; + addr.to_string (address_string); + return address_string; } int zmq::vmci_listener_t::set_local_address (const char *addr_) @@ -156,7 +90,7 @@ int zmq::vmci_listener_t::set_local_address (const char *addr_) return -1; // Create a listening socket. - s = + _s = open_socket (this->get_ctx ()->get_vmci_socket_family (), SOCK_STREAM, 0); #ifdef ZMQ_HAVE_WINDOWS if (s == INVALID_SOCKET) { @@ -165,18 +99,18 @@ int zmq::vmci_listener_t::set_local_address (const char *addr_) } #if !defined _WIN32_WCE // On Windows, preventing sockets to be inherited by child processes. - BOOL brc = SetHandleInformation ((HANDLE) s, HANDLE_FLAG_INHERIT, 0); + BOOL brc = SetHandleInformation ((HANDLE) _s, HANDLE_FLAG_INHERIT, 0); win_assert (brc); #endif #else - if (s == -1) + if (_s == -1) return -1; #endif - address.to_string (endpoint); + address.to_string (_endpoint); // Bind the socket. - rc = bind (s, address.addr (), address.addrlen ()); + rc = bind (_s, address.addr (), address.addrlen ()); #ifdef ZMQ_HAVE_WINDOWS if (rc == SOCKET_ERROR) { errno = wsa_error_to_errno (WSAGetLastError ()); @@ -188,7 +122,7 @@ int zmq::vmci_listener_t::set_local_address (const char *addr_) #endif // Listen for incoming connections. - rc = listen (s, options.backlog); + rc = listen (_s, options.backlog); #ifdef ZMQ_HAVE_WINDOWS if (rc == SOCKET_ERROR) { errno = wsa_error_to_errno (WSAGetLastError ()); @@ -199,7 +133,8 @@ int zmq::vmci_listener_t::set_local_address (const char *addr_) goto error; #endif - socket->event_listening (make_unconnected_bind_endpoint_pair (endpoint), s); + _socket->event_listening (make_unconnected_bind_endpoint_pair (_endpoint), + _s); return 0; error: @@ -209,27 +144,13 @@ int zmq::vmci_listener_t::set_local_address (const char *addr_) return -1; } -void zmq::vmci_listener_t::close () -{ - zmq_assert (s != retired_fd); -#ifdef ZMQ_HAVE_WINDOWS - int rc = closesocket (s); - wsa_assert (rc != SOCKET_ERROR); -#else - int rc = ::close (s); - errno_assert (rc == 0); -#endif - socket->event_closed (make_unconnected_bind_endpoint_pair (endpoint), s); - s = retired_fd; -} - zmq::fd_t zmq::vmci_listener_t::accept () { // Accept one connection and deal with different failure modes. // The situation where connection cannot be accepted due to insufficient // resources is considered valid and treated by ignoring the connection. - zmq_assert (s != retired_fd); - fd_t sock = ::accept (s, NULL, NULL); + zmq_assert (_s != retired_fd); + fd_t sock = ::accept (_s, NULL, NULL); #ifdef ZMQ_HAVE_WINDOWS if (sock == INVALID_SOCKET) { diff --git a/deps/zmq/src/vmci_listener.hpp b/deps/zmq/src/vmci_listener.hpp index 4ab11842ff7..b4bb653d5de 100644 --- a/deps/zmq/src/vmci_listener.hpp +++ b/deps/zmq/src/vmci_listener.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_VMCI_LISTENER_HPP_INCLUDED__ #define __ZMQ_VMCI_LISTENER_HPP_INCLUDED__ @@ -37,57 +10,37 @@ #include #include "fd.hpp" -#include "own.hpp" -#include "stdint.hpp" -#include "io_object.hpp" +#include "vmci_address.hpp" +#include "stream_listener_base.hpp" namespace zmq { -class io_thread_t; -class socket_base_t; - -// TODO consider refactoring this to derive from stream_listener_base_t -class vmci_listener_t ZMQ_FINAL : public own_t, public io_object_t +class vmci_listener_t ZMQ_FINAL : public stream_listener_base_t { public: vmci_listener_t (zmq::io_thread_t *io_thread_, zmq::socket_base_t *socket_, const options_t &options_); - ~vmci_listener_t (); // Set address to listen on. int set_local_address (const char *addr_); - // Get the bound address for use with wildcards - int get_local_address (std::string &addr_); + protected: + std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const; private: - // Handlers for incoming commands. - void process_plug (); - void process_term (int linger_); - // Handlers for I/O events. void in_event (); - // Close the listening socket. - void close (); - // Accept the new connection. Returns the file descriptor of the // newly created connection. The function may return retired_fd // if the connection was dropped while waiting in the listen backlog. fd_t accept (); - // Underlying socket. - fd_t s; - - // Handle corresponding to the listening socket. - handle_t handle; - - // Socket the listerner belongs to. - zmq::socket_base_t *socket; + int create_socket (const char *addr_); - // String representation of endpoint to bind to - std::string endpoint; + // Address to listen on. + vmci_address_t _address; ZMQ_NON_COPYABLE_NOR_MOVABLE (vmci_listener_t) }; diff --git a/deps/zmq/src/windows.hpp b/deps/zmq/src/windows.hpp index 11c7581deee..9a4e96d51c7 100644 --- a/deps/zmq/src/windows.hpp +++ b/deps/zmq/src/windows.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_WINDOWS_HPP_INCLUDED__ #define __ZMQ_WINDOWS_HPP_INCLUDED__ @@ -90,7 +63,6 @@ static inline int poll (struct pollfd *pfd, unsigned long nfds, int timeout) #ifndef AI_NUMERICSERV #define AI_NUMERICSERV 0x0400 #endif -#endif // In MSVC prior to v14, snprintf is not available // The closest implementation is the _snprintf_s function @@ -98,3 +70,15 @@ static inline int poll (struct pollfd *pfd, unsigned long nfds, int timeout) #define snprintf(buffer_, count_, format_, ...) \ _snprintf_s (buffer_, count_, _TRUNCATE, format_, __VA_ARGS__) #endif + +// Workaround missing struct sockaddr_un in afunix.h. +// Fix #3949. +#if defined(ZMQ_HAVE_IPC) && !defined(ZMQ_HAVE_STRUCT_SOCKADDR_UN) +struct sockaddr_un +{ + ADDRESS_FAMILY sun_family; /* AF_UNIX */ + char sun_path[108]; /* pathname */ +}; +#endif + +#endif diff --git a/deps/zmq/src/wire.hpp b/deps/zmq/src/wire.hpp index 47b61b0096c..53a031f376f 100644 --- a/deps/zmq/src/wire.hpp +++ b/deps/zmq/src/wire.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_WIRE_HPP_INCLUDED__ #define __ZMQ_WIRE_HPP_INCLUDED__ diff --git a/deps/zmq/src/ws_address.cpp b/deps/zmq/src/ws_address.cpp index 9e5224b9796..1b763f1862f 100644 --- a/deps/zmq/src/ws_address.cpp +++ b/deps/zmq/src/ws_address.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include diff --git a/deps/zmq/src/ws_address.hpp b/deps/zmq/src/ws_address.hpp index a5d5de8924f..94b653f481d 100644 --- a/deps/zmq/src/ws_address.hpp +++ b/deps/zmq/src/ws_address.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_WS_ADDRESS_HPP_INCLUDED__ #define __ZMQ_WS_ADDRESS_HPP_INCLUDED__ diff --git a/deps/zmq/src/ws_connecter.cpp b/deps/zmq/src/ws_connecter.cpp index f9321d9bcab..0cb69ed856d 100644 --- a/deps/zmq/src/ws_connecter.cpp +++ b/deps/zmq/src/ws_connecter.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include diff --git a/deps/zmq/src/ws_connecter.hpp b/deps/zmq/src/ws_connecter.hpp index 9755b2165f6..b67cff783da 100644 --- a/deps/zmq/src/ws_connecter.hpp +++ b/deps/zmq/src/ws_connecter.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __WS_CONNECTER_HPP_INCLUDED__ #define __WS_CONNECTER_HPP_INCLUDED__ diff --git a/deps/zmq/src/ws_decoder.cpp b/deps/zmq/src/ws_decoder.cpp index 58b12707ab4..428d0eafdcc 100644 --- a/deps/zmq/src/ws_decoder.cpp +++ b/deps/zmq/src/ws_decoder.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include diff --git a/deps/zmq/src/ws_decoder.hpp b/deps/zmq/src/ws_decoder.hpp index a12f7d1edc7..dc19aacbeae 100644 --- a/deps/zmq/src/ws_decoder.hpp +++ b/deps/zmq/src/ws_decoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_WS_DECODER_HPP_INCLUDED__ #define __ZMQ_WS_DECODER_HPP_INCLUDED__ diff --git a/deps/zmq/src/ws_encoder.cpp b/deps/zmq/src/ws_encoder.cpp index bc0b38c7ea0..0065e8bc78d 100644 --- a/deps/zmq/src/ws_encoder.cpp +++ b/deps/zmq/src/ws_encoder.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "ws_protocol.hpp" @@ -38,8 +11,7 @@ #include zmq::ws_encoder_t::ws_encoder_t (size_t bufsize_, bool must_mask_) : - encoder_base_t (bufsize_), - _must_mask (must_mask_) + encoder_base_t (bufsize_), _must_mask (must_mask_) { // Write 0 bytes to the batch and go to message_ready state. next_step (NULL, 0, &ws_encoder_t::message_ready, true); diff --git a/deps/zmq/src/ws_encoder.hpp b/deps/zmq/src/ws_encoder.hpp index 299259a7c5e..21166574ce4 100644 --- a/deps/zmq/src/ws_encoder.hpp +++ b/deps/zmq/src/ws_encoder.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_WS_ENCODER_HPP_INCLUDED__ #define __ZMQ_WS_ENCODER_HPP_INCLUDED__ diff --git a/deps/zmq/src/ws_engine.cpp b/deps/zmq/src/ws_engine.cpp index a239330cb44..9eec0d929cf 100644 --- a/deps/zmq/src/ws_engine.cpp +++ b/deps/zmq/src/ws_engine.cpp @@ -1,31 +1,4 @@ -/* -Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - -This file is part of libzmq, the ZeroMQ core engine in C++. - -libzmq is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser General Public License (LGPL) as published -by the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -As a special exception, the Contributors give you permission to link -this library with independent modules to produce an executable, -regardless of the license terms of these independent modules, and to -copy and distribute the resulting executable under terms of your choice, -provided that you also meet, for each linked independent module, the -terms and conditions of the license of that module. An independent -module is a module which is not derived from or based on this library. -If you modify this library, you must extend this exception to your -version of the library. - -libzmq is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" @@ -136,7 +109,7 @@ void zmq::ws_engine_t::start_ws_handshake () protocol = "ZWS2.0/CURVE"; #endif else { - // Avoid unitialized variable error breaking UWP build + // Avoid uninitialized variable error breaking UWP build protocol = ""; assert (false); } @@ -453,11 +426,20 @@ bool zmq::ws_engine_t::server_handshake () if (strcasecmp ("upgrade", _header_name) == 0) _header_upgrade_websocket = strcasecmp ("websocket", _header_value) == 0; - else if (strcasecmp ("connection", _header_name) == 0) - _header_connection_upgrade = - strcasecmp ("upgrade", _header_value) == 0; - else if (strcasecmp ("Sec-WebSocket-Key", _header_name) - == 0) + else if (strcasecmp ("connection", _header_name) == 0) { + char *rest = NULL; + char *element = strtok_r (_header_value, ",", &rest); + while (element != NULL) { + while (*element == ' ') + element++; + if (strcasecmp ("upgrade", element) == 0) { + _header_connection_upgrade = true; + break; + } + element = strtok_r (NULL, ",", &rest); + } + } else if (strcasecmp ("Sec-WebSocket-Key", _header_name) + == 0) strcpy_s (_websocket_key, _header_value); else if (strcasecmp ("Sec-WebSocket-Protocol", _header_name) == 0) { @@ -465,7 +447,7 @@ bool zmq::ws_engine_t::server_handshake () // Sec-WebSocket-Protocol can appear multiple times or be a comma separated list // if _websocket_protocol is already set we skip the check if (_websocket_protocol[0] == '\0') { - char *rest = 0; + char *rest = NULL; char *p = strtok_r (_header_value, ",", &rest); while (p != NULL) { if (*p == ' ') diff --git a/deps/zmq/src/ws_engine.hpp b/deps/zmq/src/ws_engine.hpp index bdf145b885f..167b9fe69ad 100644 --- a/deps/zmq/src/ws_engine.hpp +++ b/deps/zmq/src/ws_engine.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_WS_ENGINE_HPP_INCLUDED__ #define __ZMQ_WS_ENGINE_HPP_INCLUDED__ diff --git a/deps/zmq/src/ws_listener.cpp b/deps/zmq/src/ws_listener.cpp index 2c7978baade..1516813742d 100644 --- a/deps/zmq/src/ws_listener.cpp +++ b/deps/zmq/src/ws_listener.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -70,8 +43,7 @@ zmq::ws_listener_t::ws_listener_t (io_thread_t *io_thread_, socket_base_t *socket_, const options_t &options_, bool wss_) : - stream_listener_base_t (io_thread_, socket_, options_), - _wss (wss_) + stream_listener_base_t (io_thread_, socket_, options_), _wss (wss_) { #ifdef ZMQ_HAVE_WSS if (_wss) { diff --git a/deps/zmq/src/ws_listener.hpp b/deps/zmq/src/ws_listener.hpp index 88f3b08becb..60b043d1831 100644 --- a/deps/zmq/src/ws_listener.hpp +++ b/deps/zmq/src/ws_listener.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_WS_LISTENER_HPP_INCLUDED__ #define __ZMQ_WS_LISTENER_HPP_INCLUDED__ diff --git a/deps/zmq/src/ws_protocol.hpp b/deps/zmq/src/ws_protocol.hpp index b4b7e81f6b0..e80c33391f9 100644 --- a/deps/zmq/src/ws_protocol.hpp +++ b/deps/zmq/src/ws_protocol.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_WS_PROTOCOL_HPP_INCLUDED__ #define __ZMQ_WS_PROTOCOL_HPP_INCLUDED__ diff --git a/deps/zmq/src/wss_address.cpp b/deps/zmq/src/wss_address.cpp index abfec9ebf64..e26003decb5 100644 --- a/deps/zmq/src/wss_address.cpp +++ b/deps/zmq/src/wss_address.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include diff --git a/deps/zmq/src/wss_address.hpp b/deps/zmq/src/wss_address.hpp index ec6a903389d..9fe233f9341 100644 --- a/deps/zmq/src/wss_address.hpp +++ b/deps/zmq/src/wss_address.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_WSS_ADDRESS_HPP_INCLUDED__ #define __ZMQ_WSS_ADDRESS_HPP_INCLUDED__ diff --git a/deps/zmq/src/wss_engine.cpp b/deps/zmq/src/wss_engine.cpp index 986a6a4f134..300ae24bab3 100644 --- a/deps/zmq/src/wss_engine.cpp +++ b/deps/zmq/src/wss_engine.cpp @@ -1,31 +1,4 @@ -/* -Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - -This file is part of libzmq, the ZeroMQ core engine in C++. - -libzmq is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser General Public License (LGPL) as published -by the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -As a special exception, the Contributors give you permission to link -this library with independent modules to produce an executable, -regardless of the license terms of these independent modules, and to -copy and distribute the resulting executable under terms of your choice, -provided that you also meet, for each linked independent module, the -terms and conditions of the license of that module. An independent -module is a module which is not derived from or based on this library. -If you modify this library, you must extend this exception to your -version of the library. - -libzmq is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "wss_engine.hpp" @@ -194,6 +167,11 @@ int zmq::wss_engine_t::read (void *data_, size_t size_) return -1; } + if (rc == 0) { + errno = EPIPE; + return -1; + } + if (rc < 0) { errno = EINVAL; return -1; @@ -207,14 +185,8 @@ int zmq::wss_engine_t::write (const void *data_, size_t size_) { ssize_t rc = gnutls_record_send (_tls_session, data_, size_); - if (rc == GNUTLS_E_INTERRUPTED) { - errno = EINTR; - return -1; - } - - if (rc == GNUTLS_E_AGAIN) { - errno = EAGAIN; - return -1; + if (rc == GNUTLS_E_INTERRUPTED || rc == GNUTLS_E_AGAIN) { + return 0; } if (rc < 0) { diff --git a/deps/zmq/src/wss_engine.hpp b/deps/zmq/src/wss_engine.hpp index 0280c38a842..036f24e277d 100644 --- a/deps/zmq/src/wss_engine.hpp +++ b/deps/zmq/src/wss_engine.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_WSS_ENGINE_HPP_INCLUDED__ #define __ZMQ_WSS_ENGINE_HPP_INCLUDED__ diff --git a/deps/zmq/src/xpub.cpp b/deps/zmq/src/xpub.cpp index e806b8e4de3..b09cec1b9ca 100644 --- a/deps/zmq/src/xpub.cpp +++ b/deps/zmq/src/xpub.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -255,6 +228,21 @@ int zmq::xpub_t::xsetsockopt (int option_, return 0; } +int zmq::xpub_t::xgetsockopt (int option_, void *optval_, size_t *optvallen_) +{ + if (option_ == ZMQ_TOPICS_COUNT) { + // make sure to use a multi-thread safe function to avoid race conditions with I/O threads + // where subscriptions are processed: + return do_getsockopt (optval_, optvallen_, + (int) _subscriptions.num_prefixes ()); + } + + // room for future options here + + errno = EINVAL; + return -1; +} + static void stub (zmq::mtrie_t::prefix_t data_, size_t size_, void *arg_) { LIBZMQ_UNUSED (data_); @@ -272,6 +260,12 @@ void zmq::xpub_t::xpipe_terminated (pipe_t *pipe_) // care of by the manual call above. subscriptions is the real mtrie, // so the pipe must be removed from there or it will be left over. _subscriptions.rm (pipe_, stub, static_cast (NULL), false); + + // In case the pipe is currently set as last we must clear it to prevent + // subscriptions from being re-added. + if (pipe_ == _last_pipe) { + _last_pipe = NULL; + } } else { // Remove the pipe from the trie. If there are topics that nobody // is interested in anymore, send corresponding unsubscriptions @@ -348,6 +342,12 @@ int zmq::xpub_t::xrecv (msg_t *msg_) if (_manual && !_pending_pipes.empty ()) { _last_pipe = _pending_pipes.front (); _pending_pipes.pop_front (); + + // If the distributor doesn't know about this pipe it must have already + // been terminated and thus we can't allow manual subscriptions. + if (_last_pipe != NULL && !_dist.has_pipe (_last_pipe)) { + _last_pipe = NULL; + } } int rc = msg_->close (); diff --git a/deps/zmq/src/xpub.hpp b/deps/zmq/src/xpub.hpp index 82504b0e227..9a0693f504f 100644 --- a/deps/zmq/src/xpub.hpp +++ b/deps/zmq/src/xpub.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_XPUB_HPP_INCLUDED__ #define __ZMQ_XPUB_HPP_INCLUDED__ @@ -62,6 +35,7 @@ class xpub_t : public socket_base_t void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; int xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL; + int xgetsockopt (int option_, void *optval_, size_t *optvallen_) ZMQ_FINAL; void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; private: diff --git a/deps/zmq/src/xsub.cpp b/deps/zmq/src/xsub.cpp index 66c4d16b131..a82d3a08889 100644 --- a/deps/zmq/src/xsub.cpp +++ b/deps/zmq/src/xsub.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include @@ -36,6 +9,7 @@ zmq::xsub_t::xsub_t (class ctx_t *parent_, uint32_t tid_, int sid_) : socket_base_t (parent_, tid_, sid_), + _verbose_unsubs (false), _has_message (false), _more_send (false), _more_recv (false), @@ -110,6 +84,33 @@ int zmq::xsub_t::xsetsockopt (int option_, _only_first_subscribe = (*static_cast (optval_) != 0); return 0; } +#ifdef ZMQ_BUILD_DRAFT_API + else if (option_ == ZMQ_XSUB_VERBOSE_UNSUBSCRIBE) { + _verbose_unsubs = (*static_cast (optval_) != 0); + return 0; + } +#endif + errno = EINVAL; + return -1; +} + +int zmq::xsub_t::xgetsockopt (int option_, void *optval_, size_t *optvallen_) +{ + if (option_ == ZMQ_TOPICS_COUNT) { + // make sure to use a multi-thread safe function to avoid race conditions with I/O threads + // where subscriptions are processed: +#ifdef ZMQ_USE_RADIX_TREE + uint64_t num_subscriptions = _subscriptions.size (); +#else + uint64_t num_subscriptions = _subscriptions.num_prefixes (); +#endif + + return do_getsockopt (optval_, optvallen_, + (int) num_subscriptions); + } + + // room for future options here + errno = EINVAL; return -1; } @@ -132,7 +133,7 @@ int zmq::xsub_t::xsend (msg_t *msg_) if (msg_->is_subscribe () || (size > 0 && *data == 1)) { // Process subscribe message // This used to filter out duplicate subscriptions, - // however this is alread done on the XPUB side and + // however this is already done on the XPUB side and // doing it here as well breaks ZMQ_XPUB_VERBOSE // when there are forwarding devices involved. if (!msg_->is_subscribe ()) { @@ -150,7 +151,8 @@ int zmq::xsub_t::xsend (msg_t *msg_) size = size - 1; } _process_subscribe = true; - if (_subscriptions.rm (data, size)) + const bool rm_result = _subscriptions.rm (data, size); + if (rm_result || _verbose_unsubs) return _dist.send_to_all (msg_); } else // User message sent upstream to XPUB socket diff --git a/deps/zmq/src/xsub.hpp b/deps/zmq/src/xsub.hpp index 6bbbce0724f..01f5235513f 100644 --- a/deps/zmq/src/xsub.hpp +++ b/deps/zmq/src/xsub.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_XSUB_HPP_INCLUDED__ #define __ZMQ_XSUB_HPP_INCLUDED__ @@ -60,6 +33,7 @@ class xsub_t : public socket_base_t int xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_OVERRIDE; + int xgetsockopt (int option_, void *optval_, size_t *optvallen_) ZMQ_FINAL; int xsend (zmq::msg_t *msg_) ZMQ_OVERRIDE; bool xhas_out () ZMQ_OVERRIDE; int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; @@ -88,9 +62,13 @@ class xsub_t : public socket_base_t #ifdef ZMQ_USE_RADIX_TREE radix_tree_t _subscriptions; #else - trie_t _subscriptions; + trie_with_size_t _subscriptions; #endif + // If true, send all unsubscription messages upstream, not just + // unique ones + bool _verbose_unsubs; + // If true, 'message' contains a matching message to return on the // next recv call. bool _has_message; diff --git a/deps/zmq/src/ypipe.hpp b/deps/zmq/src/ypipe.hpp index e30878f9f31..4b49264c9a2 100644 --- a/deps/zmq/src/ypipe.hpp +++ b/deps/zmq/src/ypipe.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_YPIPE_HPP_INCLUDED__ #define __ZMQ_YPIPE_HPP_INCLUDED__ @@ -77,7 +50,7 @@ template class ypipe_t ZMQ_FINAL : public ypipe_base_t _queue.back () = value_; _queue.push (); - // Move the "flush up to here" poiter. + // Move the "flush up to here" pointer. if (!incomplete_) _f = &_queue.back (); } @@ -108,7 +81,7 @@ template class ypipe_t ZMQ_FINAL : public ypipe_base_t // Try to set 'c' to 'f'. if (_c.cas (_w, _f) != _w) { - // Compare-and-swap was unseccessful because 'c' is NULL. + // Compare-and-swap was unsuccessful because 'c' is NULL. // This means that the reader is asleep. Therefore we don't // care about thread-safeness and update c in non-atomic // manner. We'll return false to let the caller know @@ -163,7 +136,7 @@ template class ypipe_t ZMQ_FINAL : public ypipe_base_t return true; } - // Applies the function fn to the first elemenent in the pipe + // Applies the function fn to the first element in the pipe // and returns the value returned by the fn. // The pipe mustn't be empty or the function crashes. bool probe (bool (*fn_) (const T &)) diff --git a/deps/zmq/src/ypipe_base.hpp b/deps/zmq/src/ypipe_base.hpp index 50a534f8e16..b0e51e68997 100644 --- a/deps/zmq/src/ypipe_base.hpp +++ b/deps/zmq/src/ypipe_base.hpp @@ -1,32 +1,5 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_YPIPE_BASE_HPP_INCLUDED__ #define __ZMQ_YPIPE_BASE_HPP_INCLUDED__ diff --git a/deps/zmq/src/ypipe_conflate.hpp b/deps/zmq/src/ypipe_conflate.hpp index aa0731d10ec..c2b31a96ece 100644 --- a/deps/zmq/src/ypipe_conflate.hpp +++ b/deps/zmq/src/ypipe_conflate.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_YPIPE_CONFLATE_HPP_INCLUDED__ #define __ZMQ_YPIPE_CONFLATE_HPP_INCLUDED__ @@ -69,13 +42,19 @@ template class ypipe_conflate_t ZMQ_FINAL : public ypipe_base_t #endif // There are no incomplete items for conflate ypipe - bool unwrite (T *) { return false; } + bool unwrite (T *) + { + return false; + } // Flush is no-op for conflate ypipe. Reader asleep behaviour // is as of the usual ypipe. // Returns false if the reader thread is sleeping. In that case, // caller is obliged to wake the reader up before using the pipe again. - bool flush () { return reader_awake; } + bool flush () + { + return reader_awake; + } // Check whether item is available for reading. bool check_read () @@ -97,10 +76,13 @@ template class ypipe_conflate_t ZMQ_FINAL : public ypipe_base_t return dbuffer.read (value_); } - // Applies the function fn to the first elemenent in the pipe + // Applies the function fn to the first element in the pipe // and returns the value returned by the fn. // The pipe mustn't be empty or the function crashes. - bool probe (bool (*fn_) (const T &)) { return dbuffer.probe (fn_); } + bool probe (bool (*fn_) (const T &)) + { + return dbuffer.probe (fn_); + } protected: dbuffer_t dbuffer; diff --git a/deps/zmq/src/yqueue.hpp b/deps/zmq/src/yqueue.hpp old mode 100644 new mode 100755 index 6ba634a3fbd..1fd3fa79be9 --- a/deps/zmq/src/yqueue.hpp +++ b/deps/zmq/src/yqueue.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_YQUEUE_HPP_INCLUDED__ #define __ZMQ_YQUEUE_HPP_INCLUDED__ @@ -35,6 +8,7 @@ #include "err.hpp" #include "atomic_ptr.hpp" +#include "platform.hpp" namespace zmq { @@ -50,7 +24,7 @@ namespace zmq // T is the type of the object in the queue. // N is granularity of the queue (how many pushes have to be done till // actual memory allocation is required). -#ifdef HAVE_POSIX_MEMALIGN +#if defined HAVE_POSIX_MEMALIGN // ALIGN is the memory alignment size to use in the case where we have // posix_memalign available. Default value is 64, this alignment will // prevent two queue chunks from occupying the same CPU cache line on @@ -181,7 +155,7 @@ template class yqueue_t static inline chunk_t *allocate_chunk () { -#ifdef HAVE_POSIX_MEMALIGN +#if defined HAVE_POSIX_MEMALIGN void *pv; if (posix_memalign (&pv, ALIGN, sizeof (chunk_t)) == 0) return (chunk_t *) pv; diff --git a/deps/zmq/src/zap_client.cpp b/deps/zmq/src/zap_client.cpp index 7ba28c91cd2..521e2a9e769 100644 --- a/deps/zmq/src/zap_client.cpp +++ b/deps/zmq/src/zap_client.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" @@ -44,8 +17,7 @@ const size_t id_len = sizeof (id) - 1; zap_client_t::zap_client_t (session_base_t *const session_, const std::string &peer_address_, const options_t &options_) : - mechanism_base_t (session_, options_), - peer_address (peer_address_) + mechanism_base_t (session_, options_), peer_address (peer_address_) { } diff --git a/deps/zmq/src/zap_client.hpp b/deps/zmq/src/zap_client.hpp index 970a03799aa..b4b7341a48f 100644 --- a/deps/zmq/src/zap_client.hpp +++ b/deps/zmq/src/zap_client.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_ZAP_CLIENT_HPP_INCLUDED__ #define __ZMQ_ZAP_CLIENT_HPP_INCLUDED__ diff --git a/deps/zmq/src/zmq.cpp b/deps/zmq/src/zmq.cpp index 2c2e3d52f72..e0090dcde8e 100644 --- a/deps/zmq/src/zmq.cpp +++ b/deps/zmq/src/zmq.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ // "Tell them I was a writer. // A maker of software. @@ -97,6 +70,11 @@ struct iovec #include "ip.hpp" #include "address.hpp" +#ifdef ZMQ_HAVE_PPOLL +#include "polling_util.hpp" +#include +#endif + #if defined ZMQ_HAVE_OPENPGM #define __PGM_WININT_H__ #include @@ -1148,6 +1126,304 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) #endif } +#ifdef ZMQ_HAVE_PPOLL +// return values of 0 or -1 should be returned from zmq_poll; return value 1 means items passed checks +int zmq_poll_check_items_ (zmq_pollitem_t *items_, int nitems_, long timeout_) +{ + if (unlikely (nitems_ < 0)) { + errno = EINVAL; + return -1; + } + if (unlikely (nitems_ == 0)) { + if (timeout_ == 0) + return 0; +#if defined ZMQ_HAVE_WINDOWS + Sleep (timeout_ > 0 ? timeout_ : INFINITE); + return 0; +#elif defined ZMQ_HAVE_VXWORKS + struct timespec ns_; + ns_.tv_sec = timeout_ / 1000; + ns_.tv_nsec = timeout_ % 1000 * 1000000; + return nanosleep (&ns_, 0); +#else + return usleep (timeout_ * 1000); +#endif + } + if (!items_) { + errno = EFAULT; + return -1; + } + return 1; +} + +struct zmq_poll_select_fds_t_ +{ + explicit zmq_poll_select_fds_t_ (int nitems_) : + pollset_in (nitems_), + pollset_out (nitems_), + pollset_err (nitems_), + inset (nitems_), + outset (nitems_), + errset (nitems_), + maxfd (0) + { + FD_ZERO (pollset_in.get ()); + FD_ZERO (pollset_out.get ()); + FD_ZERO (pollset_err.get ()); + } + + zmq::optimized_fd_set_t pollset_in; + zmq::optimized_fd_set_t pollset_out; + zmq::optimized_fd_set_t pollset_err; + zmq::optimized_fd_set_t inset; + zmq::optimized_fd_set_t outset; + zmq::optimized_fd_set_t errset; + zmq::fd_t maxfd; +}; + +zmq_poll_select_fds_t_ +zmq_poll_build_select_fds_ (zmq_pollitem_t *items_, int nitems_, int &rc) +{ + // Ensure we do not attempt to select () on more than FD_SETSIZE + // file descriptors. + // TODO since this function is called by a client, we could return errno EINVAL/ENOMEM/... here + zmq_assert (nitems_ <= FD_SETSIZE); + + zmq_poll_select_fds_t_ fds (nitems_); + + // Build the fd_sets for passing to select (). + for (int i = 0; i != nitems_; i++) { + // If the poll item is a 0MQ socket we are interested in input on the + // notification file descriptor retrieved by the ZMQ_FD socket option. + if (items_[i].socket) { + size_t zmq_fd_size = sizeof (zmq::fd_t); + zmq::fd_t notify_fd; + if (zmq_getsockopt (items_[i].socket, ZMQ_FD, ¬ify_fd, + &zmq_fd_size) + == -1) { + rc = -1; + return fds; + } + if (items_[i].events) { + FD_SET (notify_fd, fds.pollset_in.get ()); + if (fds.maxfd < notify_fd) + fds.maxfd = notify_fd; + } + } + // Else, the poll item is a raw file descriptor. Convert the poll item + // events to the appropriate fd_sets. + else { + if (items_[i].events & ZMQ_POLLIN) + FD_SET (items_[i].fd, fds.pollset_in.get ()); + if (items_[i].events & ZMQ_POLLOUT) + FD_SET (items_[i].fd, fds.pollset_out.get ()); + if (items_[i].events & ZMQ_POLLERR) + FD_SET (items_[i].fd, fds.pollset_err.get ()); + if (fds.maxfd < items_[i].fd) + fds.maxfd = items_[i].fd; + } + } + + rc = 0; + return fds; +} + +timeval *zmq_poll_select_set_timeout_ ( + long timeout_, bool first_pass, uint64_t now, uint64_t end, timeval &timeout) +{ + timeval *ptimeout; + if (first_pass) { + timeout.tv_sec = 0; + timeout.tv_usec = 0; + ptimeout = &timeout; + } else if (timeout_ < 0) + ptimeout = NULL; + else { + timeout.tv_sec = static_cast ((end - now) / 1000); + timeout.tv_usec = static_cast ((end - now) % 1000 * 1000); + ptimeout = &timeout; + } + return ptimeout; +} + +timespec *zmq_poll_select_set_timeout_ ( + long timeout_, bool first_pass, uint64_t now, uint64_t end, timespec &timeout) +{ + timespec *ptimeout; + if (first_pass) { + timeout.tv_sec = 0; + timeout.tv_nsec = 0; + ptimeout = &timeout; + } else if (timeout_ < 0) + ptimeout = NULL; + else { + timeout.tv_sec = static_cast ((end - now) / 1000); + timeout.tv_nsec = static_cast ((end - now) % 1000 * 1000000); + ptimeout = &timeout; + } + return ptimeout; +} + +int zmq_poll_select_check_events_ (zmq_pollitem_t *items_, + int nitems_, + zmq_poll_select_fds_t_ &fds, + int &nevents) +{ + // Check for the events. + for (int i = 0; i != nitems_; i++) { + items_[i].revents = 0; + + // The poll item is a 0MQ socket. Retrieve pending events + // using the ZMQ_EVENTS socket option. + if (items_[i].socket) { + size_t zmq_events_size = sizeof (uint32_t); + uint32_t zmq_events; + if (zmq_getsockopt (items_[i].socket, ZMQ_EVENTS, &zmq_events, + &zmq_events_size) + == -1) + return -1; + if ((items_[i].events & ZMQ_POLLOUT) && (zmq_events & ZMQ_POLLOUT)) + items_[i].revents |= ZMQ_POLLOUT; + if ((items_[i].events & ZMQ_POLLIN) && (zmq_events & ZMQ_POLLIN)) + items_[i].revents |= ZMQ_POLLIN; + } + // Else, the poll item is a raw file descriptor, simply convert + // the events to zmq_pollitem_t-style format. + else { + if (FD_ISSET (items_[i].fd, fds.inset.get ())) + items_[i].revents |= ZMQ_POLLIN; + if (FD_ISSET (items_[i].fd, fds.outset.get ())) + items_[i].revents |= ZMQ_POLLOUT; + if (FD_ISSET (items_[i].fd, fds.errset.get ())) + items_[i].revents |= ZMQ_POLLERR; + } + + if (items_[i].revents) + nevents++; + } + + return 0; +} + +bool zmq_poll_must_break_loop_ (long timeout_, + int nevents, + bool &first_pass, + zmq::clock_t &clock, + uint64_t &now, + uint64_t &end) +{ + // If timeout is zero, exit immediately whether there are events or not. + if (timeout_ == 0) + return true; + + // If there are events to return, we can exit immediately. + if (nevents) + return true; + + // At this point we are meant to wait for events but there are none. + // If timeout is infinite we can just loop until we get some events. + if (timeout_ < 0) { + if (first_pass) + first_pass = false; + return false; + } + + // The timeout is finite and there are no events. In the first pass + // we get a timestamp of when the polling have begun. (We assume that + // first pass have taken negligible time). We also compute the time + // when the polling should time out. + if (first_pass) { + now = clock.now_ms (); + end = now + timeout_; + if (now == end) + return true; + first_pass = false; + return false; + } + + // Find out whether timeout have expired. + now = clock.now_ms (); + if (now >= end) + return true; + + // finally, in all other cases, we just continue + return false; +} +#endif // ZMQ_HAVE_PPOLL + +#if !defined _WIN32 +int zmq_ppoll (zmq_pollitem_t *items_, + int nitems_, + long timeout_, + const sigset_t *sigmask_) +#else +// Windows has no sigset_t +int zmq_ppoll (zmq_pollitem_t *items_, + int nitems_, + long timeout_, + const void *sigmask_) +#endif +{ +#ifdef ZMQ_HAVE_PPOLL + int rc = zmq_poll_check_items_ (items_, nitems_, timeout_); + if (rc <= 0) { + return rc; + } + + zmq::clock_t clock; + uint64_t now = 0; + uint64_t end = 0; + zmq_poll_select_fds_t_ fds = + zmq_poll_build_select_fds_ (items_, nitems_, rc); + if (rc == -1) { + return -1; + } + + bool first_pass = true; + int nevents = 0; + + while (true) { + // Compute the timeout for the subsequent poll. + timespec timeout; + timespec *ptimeout = zmq_poll_select_set_timeout_ (timeout_, first_pass, + now, end, timeout); + + // Wait for events. Ignore interrupts if there's infinite timeout. + while (true) { + memcpy (fds.inset.get (), fds.pollset_in.get (), + zmq::valid_pollset_bytes (*fds.pollset_in.get ())); + memcpy (fds.outset.get (), fds.pollset_out.get (), + zmq::valid_pollset_bytes (*fds.pollset_out.get ())); + memcpy (fds.errset.get (), fds.pollset_err.get (), + zmq::valid_pollset_bytes (*fds.pollset_err.get ())); + int rc = + pselect (fds.maxfd + 1, fds.inset.get (), fds.outset.get (), + fds.errset.get (), ptimeout, sigmask_); + if (unlikely (rc == -1)) { + errno_assert (errno == EINTR || errno == EBADF); + return -1; + } + break; + } + + rc = zmq_poll_select_check_events_ (items_, nitems_, fds, nevents); + if (rc < 0) { + return rc; + } + + if (zmq_poll_must_break_loop_ (timeout_, nevents, first_pass, clock, + now, end)) { + break; + } + } + + return nevents; +#else + errno = ENOTSUP; + return -1; +#endif // ZMQ_HAVE_PPOLL +} + // The poller functionality void *zmq_poller_new (void) @@ -1453,6 +1729,7 @@ int zmq_proxy (void *frontend_, void *backend_, void *capture_) errno = EFAULT; return -1; } + // Runs zmq::proxy_steerable with a NULL control_. return zmq::proxy (static_cast (frontend_), static_cast (backend_), static_cast (capture_)); @@ -1467,10 +1744,10 @@ int zmq_proxy_steerable (void *frontend_, errno = EFAULT; return -1; } - return zmq::proxy (static_cast (frontend_), - static_cast (backend_), - static_cast (capture_), - static_cast (control_)); + return zmq::proxy_steerable (static_cast (frontend_), + static_cast (backend_), + static_cast (capture_), + static_cast (control_)); } // The deprecated device functionality diff --git a/deps/zmq/src/zmq_draft.h b/deps/zmq/src/zmq_draft.h index b384d035ed3..ce5a04dd179 100644 --- a/deps/zmq/src/zmq_draft.h +++ b/deps/zmq/src/zmq_draft.h @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_DRAFT_H_INCLUDED__ #define __ZMQ_DRAFT_H_INCLUDED__ @@ -69,11 +42,30 @@ #define ZMQ_HELLO_MSG 110 #define ZMQ_DISCONNECT_MSG 111 #define ZMQ_PRIORITY 112 +#define ZMQ_BUSY_POLL 113 +#define ZMQ_HICCUP_MSG 114 +#define ZMQ_XSUB_VERBOSE_UNSUBSCRIBE 115 +#define ZMQ_TOPICS_COUNT 116 +#define ZMQ_NORM_MODE 117 +#define ZMQ_NORM_UNICAST_NACK 118 +#define ZMQ_NORM_BUFFER_SIZE 119 +#define ZMQ_NORM_SEGMENT_SIZE 120 +#define ZMQ_NORM_BLOCK_SIZE 121 +#define ZMQ_NORM_NUM_PARITY 122 +#define ZMQ_NORM_NUM_AUTOPARITY 123 +#define ZMQ_NORM_PUSH 124 + +/* DRAFT ZMQ_NORM_MODE options */ +#define ZMQ_NORM_FIXED 0 +#define ZMQ_NORM_CC 1 +#define ZMQ_NORM_CCL 2 +#define ZMQ_NORM_CCE 3 +#define ZMQ_NORM_CCE_ECNONLY 4 /* DRAFT ZMQ_RECONNECT_STOP options */ #define ZMQ_RECONNECT_STOP_CONN_REFUSED 0x1 #define ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED 0x2 -#define ZMQ_RECONNECT_STOP_AFTER_DISCONNECT 0x3 +#define ZMQ_RECONNECT_STOP_AFTER_DISCONNECT 0x4 /* DRAFT Context options */ #define ZMQ_ZERO_COPY_RECV 10 @@ -167,6 +159,19 @@ int zmq_socket_monitor_versioned ( void *s_, const char *addr_, uint64_t events_, int event_version_, int type_); int zmq_socket_monitor_pipes_stats (void *s_); +#if !defined _WIN32 +int zmq_ppoll (zmq_pollitem_t *items_, + int nitems_, + long timeout_, + const sigset_t *sigmask_); +#else +// Windows has no sigset_t +int zmq_ppoll (zmq_pollitem_t *items_, + int nitems_, + long timeout_, + const void *sigmask_); +#endif + #endif // ZMQ_BUILD_DRAFT_API #endif //ifndef __ZMQ_DRAFT_H_INCLUDED__ diff --git a/deps/zmq/src/zmq_utils.cpp b/deps/zmq/src/zmq_utils.cpp index e83fc8f14ba..e7abf701ff0 100644 --- a/deps/zmq/src/zmq_utils.cpp +++ b/deps/zmq/src/zmq_utils.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2017 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" @@ -43,9 +16,7 @@ #include #endif -#if defined(ZMQ_USE_TWEETNACL) -#include "tweetnacl.h" -#elif defined(ZMQ_USE_LIBSODIUM) +#if defined(ZMQ_USE_LIBSODIUM) #include "sodium.h" #endif @@ -211,7 +182,7 @@ uint8_t *zmq_z85_decode (uint8_t *dest_, const char *string_) } // -------------------------------------------------------------------------- -// Generate a public/private keypair with tweetnacl or libsodium. +// Generate a public/private keypair with libsodium. // Generated keys will be 40 byte z85-encoded strings. // Returns 0 on success, -1 on failure, setting errno. // Sets errno = ENOTSUP in the absence of a CURVE library. @@ -243,7 +214,7 @@ int zmq_curve_keypair (char *z85_public_key_, char *z85_secret_key_) } // -------------------------------------------------------------------------- -// Derive the public key from a private key using tweetnacl or libsodium. +// Derive the public key from a private key using libsodium. // Derived key will be 40 byte z85-encoded string. // Returns 0 on success, -1 on failure, setting errno. // Sets errno = ENOTSUP in the absence of a CURVE library. diff --git a/deps/zmq/src/zmtp_engine.cpp b/deps/zmq/src/zmtp_engine.cpp index 0bde8660aa1..517959a0185 100644 --- a/deps/zmq/src/zmtp_engine.cpp +++ b/deps/zmq/src/zmtp_engine.cpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #include "precompiled.hpp" #include "macros.hpp" @@ -398,6 +371,9 @@ bool zmq::zmtp_engine_t::handshake_v3_x (const bool downgrade_sub_) error (protocol_error); return false; } +#ifndef ZMQ_HAVE_CURVE + LIBZMQ_UNUSED (downgrade_sub_); +#endif _next_msg = &zmtp_engine_t::next_handshake_command; _process_msg = &zmtp_engine_t::process_handshake_command; diff --git a/deps/zmq/src/zmtp_engine.hpp b/deps/zmq/src/zmtp_engine.hpp index 10f4134cce1..ed2d58154b8 100644 --- a/deps/zmq/src/zmtp_engine.hpp +++ b/deps/zmq/src/zmtp_engine.hpp @@ -1,31 +1,4 @@ -/* - Copyright (c) 2007-2019 Contributors as noted in the AUTHORS file - - This file is part of libzmq, the ZeroMQ core engine in C++. - - libzmq is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License (LGPL) as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - As a special exception, the Contributors give you permission to link - this library with independent modules to produce an executable, - regardless of the license terms of these independent modules, and to - copy and distribute the resulting executable under terms of your choice, - provided that you also meet, for each linked independent module, the - terms and conditions of the license of that module. An independent - module is a module which is not derived from or based on this library. - If you modify this library, you must extend this exception to your - version of the library. - - libzmq is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ +/* SPDX-License-Identifier: MPL-2.0 */ #ifndef __ZMQ_ZMTP_ENGINE_HPP_INCLUDED__ #define __ZMQ_ZMTP_ENGINE_HPP_INCLUDED__ diff --git a/deps/zmq/version.sh b/deps/zmq/version.sh index af46c1dfa84..3131bec432a 100755 --- a/deps/zmq/version.sh +++ b/deps/zmq/version.sh @@ -7,9 +7,9 @@ if [ ! -f include/zmq.h ]; then echo "version.sh: error: include/zmq.h does not exist" 1>&2 exit 1 fi -MAJOR=`egrep '^#define +ZMQ_VERSION_MAJOR +[0-9]+$' include/zmq.h` -MINOR=`egrep '^#define +ZMQ_VERSION_MINOR +[0-9]+$' include/zmq.h` -PATCH=`egrep '^#define +ZMQ_VERSION_PATCH +[0-9]+$' include/zmq.h` +MAJOR=`grep -E '^#define +ZMQ_VERSION_MAJOR +[0-9]+$' include/zmq.h` +MINOR=`grep -E '^#define +ZMQ_VERSION_MINOR +[0-9]+$' include/zmq.h` +PATCH=`grep -E '^#define +ZMQ_VERSION_PATCH +[0-9]+$' include/zmq.h` if [ -z "$MAJOR" -o -z "$MINOR" -o -z "$PATCH" ]; then echo "version.sh: error: could not extract version from include/zmq.h" 1>&2 exit 1 @@ -18,3 +18,4 @@ MAJOR=`echo $MAJOR | awk '{ print $3 }'` MINOR=`echo $MINOR | awk '{ print $3 }'` PATCH=`echo $PATCH | awk '{ print $3 }'` echo $MAJOR.$MINOR.$PATCH | tr -d '\n' + diff --git a/tools/dep_updaters/update-libzmq.sh b/tools/dep_updaters/update-libzmq.sh index cb0e9f07447..33344f54277 100755 --- a/tools/dep_updaters/update-libzmq.sh +++ b/tools/dep_updaters/update-libzmq.sh @@ -64,8 +64,7 @@ for dir in *; do if [ "$dir" = "src" ] || \ [ "$dir" = "include" ] || \ [ "$dir" = "external" ] || \ - [ "$dir" = "COPYING" ] || \ - [ "$dir" = "COPYING.LESSER" ] || \ + [ "$dir" = "LICENSE" ] || \ [ "$dir" = "version.sh" ]; then continue fi @@ -74,7 +73,7 @@ done find external -type d ! -name "external" ! -name "wepoll" -print0 | xargs -0 rm -r echo "Copying existing gyp files" -cp "$DEPS_DIR/zmq/zmq.gyp*" "$WORKSPACE/zmq" +cp "$DEPS_DIR"/zmq/zmq.gyp* "$WORKSPACE/zmq" echo "Copying existing platform.hpp file" cp "$DEPS_DIR/zmq/src/platform.hpp" "$WORKSPACE/zmq/src"