LCOV - code coverage report
Current view: top level - eventdispatcher - tcp_base.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 8 12.5 %
Date: 2019-08-10 01:48:51 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2012-2019  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/eventdispatcher
       4             : // contact@m2osw.com
       5             : //
       6             : // This program is free software; you can redistribute it and/or modify
       7             : // it under the terms of the GNU General Public License as published by
       8             : // the Free Software Foundation; either version 2 of the License, or
       9             : // (at your option) any later version.
      10             : //
      11             : // This program is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : // GNU General Public License for more details.
      15             : //
      16             : // You should have received a copy of the GNU General Public License
      17             : // along with this program; if not, write to the Free Software
      18             : // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
      19             : 
      20             : /** \file
      21             :  * \brief Event dispatch class.
      22             :  *
      23             :  * Class used to handle events.
      24             :  */
      25             : 
      26             : // make sure we use OpenSSL with multi-thread support
      27             : // (TODO: move to .cpp once we have the impl!)
      28             : #define OPENSSL_THREAD_DEFINES
      29             : 
      30             : // self
      31             : //
      32             : #include    "eventdispatcher/tcp_base.h"
      33             : 
      34             : #include    "eventdispatcher/exception.h"
      35             : #include    "eventdispatcher/tcp_private.h"
      36             : 
      37             : 
      38             : // cppthread lib
      39             : //
      40             : #include    <cppthread/guard.h>
      41             : #include    <cppthread/mutex.h>
      42             : #include    <cppthread/thread.h>
      43             : 
      44             : 
      45             : // snaplogger lib
      46             : //
      47             : #include    <snaplogger/message.h>
      48             : 
      49             : 
      50             : // snapdev lib
      51             : //
      52             : #include    <snapdev/not_used.h>
      53             : 
      54             : 
      55             : // OpenSSL lib
      56             : //
      57             : #include    <openssl/bio.h>
      58             : #include    <openssl/err.h>
      59             : #include    <openssl/ssl.h>
      60             : 
      61             : 
      62             : // last include
      63             : //
      64             : #include    <snapdev/poison.h>
      65             : 
      66             : 
      67             : 
      68             : 
      69             : #ifndef OPENSSL_THREADS
      70             : #error "OPENSSL_THREADS is not defined. Event Dispatcher requires OpenSSL to support multi-threading."
      71             : #endif
      72             : 
      73             : namespace ed
      74             : {
      75             : 
      76             : 
      77             : 
      78             : /** \brief Clean up the BIO environment.
      79             :  *
      80             :  * This function cleans up the BIO environment.
      81             :  *
      82             :  * \note
      83             :  * This function is here for documentation rather than to get called.
      84             :  * Whenever you exit a process that uses the BIO calls it will leak
      85             :  * a few things. To make the process really spanking clean, you want
      86             :  * to call this function before exit(3). You have to make sure that
      87             :  * you call this function only after every single BIO object was
      88             :  * closed and none must be opened after this call.
      89             :  */
      90           0 : void cleanup()
      91             : {
      92           0 :     detail::thread_cleanup();
      93           0 :     detail::bio_cleanup();
      94           0 : }
      95             : 
      96             : 
      97             : /** \brief Before a thread exits, this function must be called.
      98             :  *
      99             :  * Any error which is still attached to a thread must be removed
     100             :  * before the thread dies or it will be lost. This function must
     101             :  * be called before you return from your
     102             :  * snap::snap_thread::snap_runner::run()
     103             :  * function.
     104             :  *
     105             :  * The thread must be pro-active and make sure to catch() errors
     106             :  * if necessary to ensure that this function gets called before
     107             :  * it exists.
     108             :  *
     109             :  * Also, this means all BIO connections were properly terminated
     110             :  * before the thread returns.
     111             :  *
     112             :  * \note
     113             :  * TBD--this may not be required. I read a few things a while back
     114             :  * saying that certain things were now automatic in the BIO library
     115             :  * and this may very well be one of them. To test this function,
     116             :  * see the snapdbproxy/src/snapdbproxy_connection.cpp and see how
     117             :  * it works one way or the other.
     118             :  */
     119           0 : void cleanup_on_thread_exit()
     120             : {
     121           0 :     detail::per_thread_cleanup();
     122           0 : }
     123             : 
     124             : 
     125             : 
     126           6 : } // namespace ed
     127             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.12