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