if (rc < 0){
io->status = rc;
io->io_errno = EIO;
+ // We should get here only with Protocol errors, so we should terminate backends, as this is always fatal
+ cancel_all_backends(ctx);
return bRC_Error;
}
io->status = rc;
if (!backend.ctx->read_ack(ctx)){
/* should get EOD */
DMSG0(ctx, DERROR, "Protocol error, should get EOD.\n");
- backend.ctx->terminate(ctx);
+ // In protocol error situations, the communication has no chance to continue, so we need to kill the backend
+ cancel_all_backends(ctx);
return bRC_Error;
}
if (!backend.ctx->read_ack(ctx)){
/* should get EOD */
DMSG0(ctx, DERROR, "Protocol error, should get EOD.\n");
- backend.ctx->terminate(ctx);
+ // In protocol error situations, the communication has no chance to continue, so we need to kill the backend
+ cancel_all_backends(ctx);
return bRC_Error;
}
readxattr = true;
if (!backend.ctx->read_ack(ctx)){
/* should get EOD */
DMSG0(ctx, DERROR, "Protocol error, should get EOD.\n");
- backend.ctx->terminate(ctx);
+ // In protocol error situations, the communication has no chance to continue, so we need to kill the backend
+ cancel_all_backends(ctx);
return bRC_Error;
}
/* error in protocol */
DMSG(ctx, DERROR, "Protocol error, got unknown command: %s\n", cmd.c_str());
JMSG(ctx, M_FATAL, "Protocol error, got unknown command: %s\n", cmd.c_str());
- backend.ctx->terminate(ctx);
+ // In protocol error situations, the communication has no chance to continue, so we need to kill the backend
+ cancel_all_backends(ctx);
return bRC_Error;
} else {
if (backend.ctx->is_fatal()){
/* error in protocol */
DMSG(ctx, DERROR, "Protocol error, got unknown command: %s\n", cmd.c_str());
JMSG(ctx, M_FATAL, "Protocol error, got unknown command: %s\n", cmd.c_str());
- backend.ctx->terminate(ctx);
+ cancel_all_backends(ctx);
return bRC_Error;
} else {
if (backend.ctx->is_fatal()){
if (reqparams > 0) {
DMSG0(ctx, DERROR, "Protocol error, not enough file attributes from backend.\n");
JMSG0(ctx, M_FATAL, "Protocol error, not enough file attributes from backend.\n");
- backend.ctx->terminate(ctx);
+ // In protocol error situations, the communication has no chance to continue, so we need to kill the backend
+ cancel_all_backends(ctx);
return bRC_Error;
}
if (worker_pid) {
/* terminate the backend */
+ DMSG(ctx, DINFO, "Killing backend with PID=%d\n", worker_pid);
kill(worker_pid, SIGTERM);
}
DMSG0(ctx, DERROR, "PTCOMM cannot get packet header from backend.\n");
JMSG0(ctx, M_FATAL, "PTCOMM cannot get packet header from backend.\n");
f_eod = f_error = f_fatal = true;
- terminate(ctx);
return -1;
}
if (header.status == 'C' || header.status == 'D') {
if (!any) {
if (header.status != *cmd) {
- DMSG2(ctx, DERROR, "Protocol error. Expected packet: %c got: %c\n", *cmd, header.status);
- JMSG2(ctx, M_FATAL, "Protocol error. Expected packet: %c got: %c\n", *cmd, header.status);
- terminate(ctx);
+ DMSG3(ctx, DERROR, "Protocol error. Expected packet: %c got: %c:%s\n", *cmd, header.status, header.length);
+ JMSG3(ctx, M_FATAL, "Protocol error. Expected packet: %c got: %c:%s\n", *cmd, header.status, header.length);
return -1;
}
} else {
default:
DMSG2(ctx, DERROR, "Protocol error. Unknown packet: %c:%s\n", header.status, header.length);
JMSG2(ctx, M_FATAL, "Protocol error. Unknown packet: %c:%s\n", header.status, header.length);
- terminate(ctx);
return -1;
}
}