// Roll-back all services:
constexpr static int DINIT_CP_ROLLBACKALL = 2;
+// Query protocol version:
+constexpr static int DINIT_CP_QUERYVERSION = 3;
+
// Replies:
// Start service replies:
constexpr static int DINIT_RP_SERVICELOADERR = 61;
constexpr static int DINIT_RP_SERVICEOOM = 62; // couldn't start due to out-of-memory
+
+// Query version response:
+constexpr static int DINIT_RP_CPVERSION = 63;
// shouldn't touch instance members after that point.
int pktType = iobuf[0];
+ if (pktType == DINIT_CP_QUERYVERSION) {
+ // Responds with:
+ // DINIT_RP_CVERSION, (2 byte) minimum compatible version, (2 byte) maximum compatible version
+ char replyBuf[] = { DINIT_RP_CPVERSION, 0, 0, 0, 0 };
+ if (! queuePacket(replyBuf, 1)) return;
+ memmove(iobuf, iobuf + 1, 1024 - 1);
+ bufidx -= 1;
+ return;
+ }
if (pktType == DINIT_CP_STARTSERVICE || pktType == DINIT_CP_STOPSERVICE) {
if (bufidx < 4) {
chklen = 4;
if (! queuePacket(ack_buf, 1)) return;
}
catch (ServiceLoadExc &slexc) {
+ log(LogLevel::ERROR, "Could not start service ", slexc.serviceName, ": ", slexc.excDescription);
char outbuf[] = { DINIT_RP_SERVICELOADERR };
if (! queuePacket(outbuf, 1)) return;
}
return;
}
else {
- // TODO error response
+ // Unrecognized: give error response
+ char outbuf[] = { DINIT_RP_BADREQ };
+ if (! queuePacket(outbuf, 1)) return;
+ bad_conn_close = true;
+ ev_io_set(&iob, iob.fd, EV_WRITE);
}
return;
}