~ubuntu-branches/ubuntu/saucy/zeromq3/saucy

« back to all changes in this revision

Viewing changes to .pc/03_fix-test_shutdown_stress-segfault.patch/src/ipc_connecter.hpp

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2012-10-16 19:49:30 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20121016194930-98r0bi746eoaa4iv
Tags: 3.2.1~rc2+dfsg-1
* New upstream RC release (Closes: #690704)
* Bump Standards-Version to 3.9.4 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    Copyright (c) 2011 250bpm s.r.o.
3
 
    Copyright (c) 2011 Other contributors as noted in the AUTHORS file
4
 
 
5
 
    This file is part of 0MQ.
6
 
 
7
 
    0MQ is free software; you can redistribute it and/or modify it under
8
 
    the terms of the GNU Lesser General Public License as published by
9
 
    the Free Software Foundation; either version 3 of the License, or
10
 
    (at your option) any later version.
11
 
 
12
 
    0MQ is distributed in the hope that it will be useful,
13
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
    GNU Lesser General Public License for more details.
16
 
 
17
 
    You should have received a copy of the GNU Lesser General Public License
18
 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 
*/
20
 
 
21
 
#ifndef __IPC_CONNECTER_HPP_INCLUDED__
22
 
#define __IPC_CONNECTER_HPP_INCLUDED__
23
 
 
24
 
#include "platform.hpp"
25
 
 
26
 
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
27
 
 
28
 
#include "fd.hpp"
29
 
#include "own.hpp"
30
 
#include "stdint.hpp"
31
 
#include "io_object.hpp"
32
 
 
33
 
namespace zmq
34
 
{
35
 
 
36
 
    class io_thread_t;
37
 
    class session_base_t;
38
 
    struct address_t;
39
 
 
40
 
    class ipc_connecter_t : public own_t, public io_object_t
41
 
    {
42
 
    public:
43
 
 
44
 
        //  If 'delay' is true connecter first waits for a while, then starts
45
 
        //  connection process.
46
 
        ipc_connecter_t (zmq::io_thread_t *io_thread_,
47
 
            zmq::session_base_t *session_, const options_t &options_,
48
 
            const address_t *addr_, bool delay_);
49
 
        ~ipc_connecter_t ();
50
 
 
51
 
    private:
52
 
 
53
 
        //  ID of the timer used to delay the reconnection.
54
 
        enum {reconnect_timer_id = 1};
55
 
 
56
 
        //  Handlers for incoming commands.
57
 
        void process_plug ();
58
 
 
59
 
        //  Handlers for I/O events.
60
 
        void in_event ();
61
 
        void out_event ();
62
 
        void timer_event (int id_);
63
 
 
64
 
        //  Internal function to start the actual connection establishment.
65
 
        void start_connecting ();
66
 
 
67
 
        //  Internal function to add a reconnect timer
68
 
        void add_reconnect_timer();
69
 
 
70
 
        //  Internal function to return a reconnect backoff delay.
71
 
        //  Will modify the current_reconnect_ivl used for next call
72
 
        //  Returns the currently used interval
73
 
        int get_new_reconnect_ivl ();
74
 
 
75
 
        //  Open IPC connecting socket. Returns -1 in case of error,
76
 
        //  0 if connect was successfull immediately. Returns -1 with
77
 
        //  EAGAIN errno if async connect was launched.
78
 
        int open ();
79
 
 
80
 
        //  Close the connecting socket.
81
 
        int close ();
82
 
 
83
 
        //  Get the file descriptor of newly created connection. Returns
84
 
        //  retired_fd if the connection was unsuccessfull.
85
 
        fd_t connect ();
86
 
 
87
 
        //  Address to connect to. Owned by session_base_t.
88
 
        const address_t *addr;
89
 
 
90
 
        //  Underlying socket.
91
 
        fd_t s;
92
 
 
93
 
        //  Handle corresponding to the listening socket.
94
 
        handle_t handle;
95
 
 
96
 
        //  If true file descriptor is registered with the poller and 'handle'
97
 
        //  contains valid value.
98
 
        bool handle_valid;
99
 
 
100
 
        //  If true, connecter is waiting a while before trying to connect.
101
 
        bool wait;
102
 
 
103
 
        //  Reference to the session we belong to.
104
 
        zmq::session_base_t *session;
105
 
 
106
 
        //  Current reconnect ivl, updated for backoff strategy
107
 
        int current_reconnect_ivl;
108
 
 
109
 
        // String representation of endpoint to connect to
110
 
        std::string endpoint;
111
 
 
112
 
        ipc_connecter_t (const ipc_connecter_t&);
113
 
        const ipc_connecter_t &operator = (const ipc_connecter_t&);
114
 
    };
115
 
 
116
 
}
117
 
 
118
 
#endif
119
 
 
120
 
#endif
121