summaryrefslogtreecommitdiff
path: root/qpid/extras/dispatch/src/server_private.h
blob: 5782492f22a65d639d79eaab67419e17012ba0b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef __server_private_h__
#define __server_private_h__ 1
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

#include <qpid/dispatch/server.h>
#include <qpid/dispatch/user_fd.h>
#include <qpid/dispatch/timer.h>
#include <qpid/dispatch/alloc.h>
#include <proton/driver.h>
#include <proton/driver_extras.h>

void dx_server_timer_pending_LH(dx_timer_t *timer);
void dx_server_timer_cancel_LH(dx_timer_t *timer);


typedef enum {
    CONN_STATE_CONNECTING = 0,
    CONN_STATE_OPENING,
    CONN_STATE_OPERATIONAL,
    CONN_STATE_FAILED,
    CONN_STATE_USER
} conn_state_t;

#define CONTEXT_NO_OWNER -1

typedef enum {
    CXTR_STATE_CONNECTING = 0,
    CXTR_STATE_OPEN,
    CXTR_STATE_FAILED
} cxtr_state_t;

typedef struct dx_server_t dx_server_t;

struct dx_listener_t {
    dx_server_t              *server;
    const dx_server_config_t *config;
    void                     *context;
    pn_listener_t            *pn_listener;
};


struct dx_connector_t {
    dx_server_t              *server;
    cxtr_state_t              state;
    const dx_server_config_t *config;
    void                     *context;
    dx_connection_t          *ctx;
    dx_timer_t               *timer;
    long                      delay;
};


struct dx_connection_t {
    dx_server_t     *server;
    conn_state_t     state;
    int              owner_thread;
    int              enqueued;
    pn_connector_t  *pn_cxtr;
    pn_connection_t *pn_conn;
    dx_listener_t   *listener;
    dx_connector_t  *connector;
    void            *context; // Copy of context from listener or connector
    void            *user_context;
    dx_user_fd_t    *ufd;
};


struct dx_user_fd_t {
    dx_server_t    *server;
    void           *context;
    int             fd;
    pn_connector_t *pn_conn;
};


ALLOC_DECLARE(dx_listener_t);
ALLOC_DECLARE(dx_connector_t);
ALLOC_DECLARE(dx_connection_t);
ALLOC_DECLARE(dx_user_fd_t);


#endif