Differences From
Artifact [5ea8386d8f]:
195 195
196 196 cmd.cmd = m.cmd.none
197 197 end
198 198
199 199 terra m.emperor:mallack() return lib.mem.heapa(m.ack, self:countpeers()) end
200 200 terra m.emperor.methods.decree :: {
201 201 &m.emperor, uint64, rawstring, m.cmd.t, uint64, &m.ack
202 -} -> {}
202 +} -> bool
203 203 terra m.emperor:decree(
204 204 tgtclid: uint64, tgtname: rawstring,
205 205 cmd: m.cmd.t, operand: uint64,
206 206 result: &m.ack
207 -): {}
207 +): bool
208 208 if self.client then lib.bail('client attempted to issue IPC decree') end
209 209 var dem = m.demand {
210 210 cmd = cmd;
211 211 operand = operand;
212 212 empq = self.msqid; -- register to receive replies
213 213 }
214 214 var npeers = self:countpeers()
215 - if npeers == 0 then lib.bail('no processes connected to control bus') end
215 + if npeers == 0 then lib.warn('no processes connected to control bus') return false end
216 216 if tgtclid == 0 and tgtname == nil then
217 217 lib.dbg('sending to all instances, waiting for edict to become writable')
218 218 self.edict:sem(0) -- wait for all locks on edict to resolve
219 219 lib.dbg('locking edict')
220 220 self.edict:sem(npeers) -- place a read lock for each peer
221 221 self.edict.demand = dem
222 222 lib.dbg('sending edict')
................................................................................
246 246 found = true
247 247 tgt = acks(i).cliq
248 248 end
249 249 end
250 250 acks:free()
251 251 if not found then
252 252 lib.warn('no such instance is currently online and responding to IPC calls')
253 + return false
253 254 else
254 255 lib.dbg('located instance, sending command')
255 256 if mq.msgsnd(tgt, &dem, sizeof(m.demand), 0) == -1 then
256 257 lib.bail('could not send command to target process')
257 258 end
258 259 while true do
259 260 var ack: m.ack
................................................................................
264 265 lib.dbg('got response, writing out and returning')
265 266 @result = ack
266 267 break
267 268 else lib.warn('got spurious response, ignoring') end
268 269 end
269 270 end
270 271 end
272 + return true
271 273 end
272 274
273 275 terra m.demand:ack(emp: &m.emperor, a: &m.ack)
274 276 a.clid = emp.clid
275 277 a.cliq = emp.msqid
276 278 mq.msgsnd(self.empq, a, sizeof(m.ack), 0)
277 279 end