~codership/galera/3.x

« back to all changes in this revision

Viewing changes to gcomm/src/gcomm/protolay.hpp

  • Committer: Alexey Yurchenko
  • Date: 2014-02-06 19:27:50 UTC
  • mfrom: (153.2.15 2.x)
  • Revision ID: alexey.yurchenko@codership.com-20140206192750-n9to0wtjevl69gok
Tags: release_25.3.3(percona)
References lp:1260193 - all supported parameters are now registered before parsing the initial options string, so unrecognized options can be detected.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2009 Codership Oy <info@codership.com>
 
2
 * Copyright (C) 2009-2014 Codership Oy <info@codership.com>
3
3
 */
4
4
 
5
5
/*!
195
195
    CtxList     up_context_;
196
196
    CtxList     down_context_;
197
197
 
198
 
 
199
198
    Protolay (const Protolay&);
200
199
    Protolay& operator=(const Protolay&);
201
200
 
202
201
protected:
 
202
 
203
203
    gu::Config& conf_;
 
204
 
204
205
    Protolay(gu::Config& conf)
205
206
        :
206
207
        up_context_(0),
209
210
    { }
210
211
 
211
212
public:
 
213
 
212
214
    virtual ~Protolay() {}
213
215
 
214
216
    virtual void connect(bool) { }
221
223
 
222
224
    void set_up_context(Protolay *up)
223
225
    {
224
 
        if (std::find(up_context_.begin(),
 
226
        if (std::find(up_context_.begin(),
225
227
                      up_context_.end(),
226
228
                      up) != up_context_.end())
227
229
        {
228
230
            gu_throw_fatal << "up context already exists";
229
231
        }
230
 
        up_context_.push_back(up);
 
232
        up_context_.push_back(up);
231
233
    }
232
234
 
233
235
    void set_down_context(Protolay *down)
234
236
    {
235
 
        if (std::find(down_context_.begin(),
 
237
        if (std::find(down_context_.begin(),
236
238
                      down_context_.end(),
237
239
                      down) != down_context_.end())
238
240
        {
239
241
            gu_throw_fatal << "down context already exists";
240
242
        }
241
 
        down_context_.push_back(down);
 
243
        down_context_.push_back(down);
242
244
    }
243
245
 
244
246
    void unset_up_context(Protolay* up)
245
247
    {
246
248
        CtxList::iterator i;
247
 
        if ((i = std::find(up_context_.begin(),
 
249
        if ((i = std::find(up_context_.begin(),
248
250
                           up_context_.end(),
249
251
                           up)) == up_context_.end())
250
252
        {
257
259
    void unset_down_context(Protolay* down)
258
260
    {
259
261
        CtxList::iterator i;
260
 
        if ((i = std::find(down_context_.begin(),
 
262
        if ((i = std::find(down_context_.begin(),
261
263
                           down_context_.end(),
262
264
                           down)) == down_context_.end())
263
265
        {
269
271
    /* apparently passed data buffer to the upper layer */
270
272
    void send_up(const Datagram& dg, const ProtoUpMeta& up_meta)
271
273
    {
272
 
        if (up_context_.empty() == true)
 
274
        if (up_context_.empty() == true)
273
275
        {
274
 
            gu_throw_fatal << this << " up context(s) not set";
275
 
        }
 
276
            gu_throw_fatal << this << " up context(s) not set";
 
277
        }
276
278
 
277
279
        CtxList::iterator i, i_next;
278
280
        for (i = up_context_.begin(); i != up_context_.end(); i = i_next)
285
287
    /* apparently passes data buffer to lower layer, what is return value? */
286
288
    int send_down(Datagram& dg, const ProtoDownMeta& down_meta)
287
289
    {
288
 
        if (down_context_.empty() == true)
 
290
        if (down_context_.empty() == true)
289
291
        {
290
292
            log_warn << this << " down context(s) not set";
291
293
            return ENOTCONN;
292
 
        }
 
294
        }
293
295
 
294
 
        int    ret         = 0;
 
296
        int    ret         = 0;
295
297
        for (CtxList::iterator i = down_context_.begin();
296
298
             i != down_context_.end(); ++i)
297
299
        {
308
310
                ret = err;
309
311
            }
310
312
        }
311
 
        return ret;
 
313
        return ret;
312
314
    }
313
315
 
314
316
    virtual void handle_stable_view(const View& view) { }