~ubuntu-branches/ubuntu/vivid/ctdb/vivid-proposed

« back to all changes in this revision

Viewing changes to libctdb/messages.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Parent
  • Date: 2011-11-06 15:18:59 UTC
  • mfrom: (1.2.14)
  • Revision ID: package-import@ubuntu.com-20111106151859-41lblk8ml4es7ra3
Tags: 1.11+git20111102-1
* New upstream release
  - removed 92-apache-service-enable.diff: integrated 
  - removed 99-fix-broken-readdir-test.diff: integrated
* d/rules, d/control, d/compat:
  - converted to dh (% target and dh_auto_*)
  - moved to compat level 9 (buildeps upgraded)
  - dh9 enabled hardening build flags
  - added hardening=+bindnow
  - dh9 enabled multiarch
    + Don't use /use/lib64 on ppc64 (Closes: #644907)
    + libctdb-dev is Multi-Arch: same
    + removed 10_no-lib64.diff: not needed with multiarch
* ctdb.init:
  - removed gettext support
  - synced with upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   core of libctdb
 
3
 
 
4
   Copyright (C) Rusty Russell 2010
 
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 3 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, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
1
20
#include "libctdb_private.h"
2
21
#include "messages.h"
3
22
#include "io_elem.h"
41
60
        if (!found) {
42
61
                DEBUG(ctdb, LOG_WARNING,
43
62
                      "ctdb_service: messsage for unregistered srvid %llu",
44
 
                      msg->srvid);
 
63
                      (unsigned long long)msg->srvid);
45
64
        }
46
65
}
47
66
 
57
76
        }
58
77
}
59
78
 
60
 
bool ctdb_set_message_handler_recv(struct ctdb_connection *ctdb,
61
 
                                   struct ctdb_request *req)
62
 
{
63
 
        struct message_handler_info *info = req->extra;
64
 
        struct ctdb_reply_control *reply;
65
 
 
66
 
        reply = unpack_reply_control(ctdb, req, CTDB_CONTROL_REGISTER_SRVID);
67
 
        if (!reply) {
68
 
                return false;
69
 
        }
70
 
        if (reply->status != 0) {
71
 
                DEBUG(ctdb, LOG_ERR,
72
 
                      "ctdb_set_message_handler_recv: status %i",
73
 
                      reply->status);
74
 
                return false;
75
 
        }
76
 
 
77
 
        /* Put ourselves in list of handlers. */
78
 
        DLIST_ADD(ctdb->message_handlers, info);
79
 
        /* Keep safe from destructor */
80
 
        req->extra = NULL;
81
 
        return true;
82
 
}
83
 
 
84
 
static void free_info(struct ctdb_connection *ctdb, struct ctdb_request *req)
85
 
{
86
 
        free(req->extra);
87
 
}
 
79
static void free_info(struct ctdb_connection *ctdb, struct ctdb_request *req);
88
80
 
89
81
struct ctdb_request *
90
82
ctdb_set_message_handler_send(struct ctdb_connection *ctdb, uint64_t srvid,
120
112
 
121
113
        DEBUG(ctdb, LOG_DEBUG,
122
114
              "ctdb_set_message_handler_send: sending request %u for id %llx",
123
 
              req->hdr.hdr->reqid, srvid);
 
115
              req->hdr.hdr->reqid, (unsigned long long)srvid);
124
116
        return req;
125
117
}
126
118
 
 
119
static void free_info(struct ctdb_connection *ctdb, struct ctdb_request *req)
 
120
{
 
121
        free(req->extra);
 
122
}
 
123
 
 
124
bool ctdb_set_message_handler_recv(struct ctdb_connection *ctdb,
 
125
                                   struct ctdb_request *req)
 
126
{
 
127
        struct message_handler_info *info = req->extra;
 
128
        struct ctdb_reply_control *reply;
 
129
 
 
130
        reply = unpack_reply_control(req, CTDB_CONTROL_REGISTER_SRVID);
 
131
        if (!reply) {
 
132
                return false;
 
133
        }
 
134
        if (reply->status != 0) {
 
135
                DEBUG(ctdb, LOG_ERR,
 
136
                      "ctdb_set_message_handler_recv: status %i",
 
137
                      reply->status);
 
138
                return false;
 
139
        }
 
140
 
 
141
        /* Put ourselves in list of handlers. */
 
142
        DLIST_ADD(ctdb->message_handlers, info);
 
143
        /* Keep safe from destructor */
 
144
        req->extra = NULL;
 
145
        return true;
 
146
}
 
147
 
127
148
struct ctdb_request *
128
149
ctdb_remove_message_handler_send(struct ctdb_connection *ctdb, uint64_t srvid,
129
150
                                 ctdb_message_fn_t handler, void *hdata,
158
179
 
159
180
        DEBUG(ctdb, LOG_DEBUG,
160
181
              "ctdb_set_remove_handler_send: sending request %u for id %llu",
161
 
              req->hdr.hdr->reqid, srvid);
 
182
              req->hdr.hdr->reqid, (unsigned long long)srvid);
162
183
        return req;
163
184
}
164
185
 
168
189
        struct message_handler_info *handler = req->extra;
169
190
        struct ctdb_reply_control *reply;
170
191
 
171
 
        reply = unpack_reply_control(ctdb, req, CTDB_CONTROL_DEREGISTER_SRVID);
 
192
        reply = unpack_reply_control(req, CTDB_CONTROL_DEREGISTER_SRVID);
172
193
        if (!reply) {
173
194
                return false;
174
195
        }
195
216
        struct ctdb_req_message *pkt;
196
217
 
197
218
        /* We just discard it once it's finished: no reply. */
198
 
        req = new_ctdb_request(offsetof(struct ctdb_req_message, data) + data.dsize,
199
 
                               ctdb_cancel_callback, NULL);
 
219
        req = new_ctdb_request(
 
220
                ctdb, offsetof(struct ctdb_req_message, data) + data.dsize,
 
221
                ctdb_cancel_callback, NULL);
200
222
        if (!req) {
201
223
                DEBUG(ctdb, LOG_ERR, "ctdb_set_message: allocating message");
202
224
                return false;