Revision 97474282 src/rm/RequestManagerZone.cc

View differences:

src/rm/RequestManagerZone.cc
131 131

  
132 132
        int oid = zone->get_oid();
133 133

  
134
        unsigned int numservers = zone->servers_size();
135

  
134 136
        zone->to_xml(tmpl_xml);
135 137

  
136 138
        ErrorCode ec = master_update_zone(oid, tmpl_xml, att);
......
144 146
            failure_response(ec, att);
145 147
            return;
146 148
        }
149

  
150
        //Wait for zone update to propagate from master before adding the
151
        //new server
152
        if ( numservers == 2 )
153
        {
154
            bool updated = false;
155

  
156
            while (!updated) 
157
            {
158
                Zone * zone = (static_cast<ZonePool *>(pool))->get(id, true);
159

  
160
                if ( zone != 0 )
161
                {
162
                    if ( zone->get_server(zs_id) != 0 )
163
                    {
164
                        updated = true;
165
                    }
166
                }
167

  
168
                usleep(250000);
169
            }
170
        }
147 171
    }
148 172

  
149 173
	nd.get_raftm()->add_server(zs_id, xmlep);
......
196 220
        return;
197 221
    }
198 222

  
223
	nd.get_raftm()->delete_server(zs_id);
224

  
199 225
    if ( nd.is_federation_master() || !nd.is_federation_enabled() )
200 226
    {
201 227
        std::vector<int> zids;
......
227 253
        }
228 254
    }
229 255

  
230
	nd.get_raftm()->delete_server(zs_id);
231

  
232 256
    success_response(id, att);
233 257
}
234 258

  
......
501 525
        return;
502 526
    }
503 527

  
528
    if ( sql.empty() )
529
    {
530
        oss << "Received an empty SQL command at index" << index;
531

  
532
        NebulaLog::log("ReM", Log::ERROR, oss);
533

  
534
        att.resp_msg = oss.str();
535
        att.resp_id  = index;
536

  
537
        failure_response(ACTION, att);
538
        return;
539
    }
540

  
504 541
    if ( !nd.is_federation_slave() )
505 542
    {
506 543
        oss << "Cannot replicate federate log records on federation master";
......
511 548
        att.resp_id  = - 1;
512 549

  
513 550
        failure_response(ACTION, att);
551
        return;
514 552
    }
515 553

  
516 554
    int rc = frm->apply_log_record(index, sql);
......
526 564
        NebulaLog::log("ReM", Log::INFO, oss);
527 565

  
528 566
        att.resp_msg = oss.str();
529
        att.resp_id  = index - 1;
567
        att.resp_id  = index;
530 568

  
531 569
        failure_response(ACTION, att);
532 570
    }
......
544 582

  
545 583
    return;
546 584
}
585

  

Also available in: Unified diff