Commit 162bd361 authored by unknown's avatar unknown

bug#4590

Use ndb_mgm_listen_event to wait for backup messages


ndb/src/mgmclient/CommandInterpreter.cpp:
  Listen to backup event
  start backup
  wait until event related to backup arrives
ndb/src/mgmsrv/Services.cpp:
  Fix newline at end of reply
parent ef5c6152
...@@ -1672,13 +1672,45 @@ CommandInterpreter::executeStartBackup(char* /*parameters*/) ...@@ -1672,13 +1672,45 @@ CommandInterpreter::executeStartBackup(char* /*parameters*/)
connect(); connect();
struct ndb_mgm_reply reply; struct ndb_mgm_reply reply;
unsigned int backupId; unsigned int backupId;
int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 };
int fd = ndb_mgm_listen_event(m_mgmsrv, filter);
int result = ndb_mgm_start_backup(m_mgmsrv, &backupId, &reply); int result = ndb_mgm_start_backup(m_mgmsrv, &backupId, &reply);
if (result != 0) { if (result != 0) {
ndbout << "Start of backup failed" << endl; ndbout << "Start of backup failed" << endl;
printError(); printError();
} else { close(fd);
ndbout << "Backup started. Backup id " << backupId << "." << endl; return;
}
char *tmp;
char buf[1024];
{
SocketInputStream in(fd);
int count = 0;
do {
tmp = in.gets(buf, 1024);
if(tmp)
{
ndbout << tmp;
int id;
if(sscanf(tmp, "%*[^:]: Backup %d ", &id) == 1 && id == backupId){
count++;
} }
}
} while(count < 2);
}
SocketInputStream in(fd, 10);
do {
tmp = in.gets(buf, 1024);
if(tmp && tmp[0] != 0)
{
ndbout << tmp;
}
} while(tmp && tmp[0] != 0);
close(fd);
} }
void void
......
...@@ -1411,6 +1411,7 @@ done: ...@@ -1411,6 +1411,7 @@ done:
m_output->println("result: %d", result); m_output->println("result: %d", result);
if(result != 0) if(result != 0)
m_output->println("msg: %s", msg.c_str()); m_output->println("msg: %s", msg.c_str());
m_output->println("");
} }
template class MutexVector<int>; template class MutexVector<int>;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment