len = edg_wll_plain_read_full(data->conn, buffer, max_len, &data->ctx->p_tmp_timeout);
if(len < 0)
- edg_wll_SetError(data->ctx, LB_PROTO, "get_reply_plain(): error reading message data");
+ edg_wll_SetError(data->ctx, EDG_WLL_IL_PROTO, "plain_reader(): error reading message data");
return(len);
}
*/
static
int
-get_reply_plain(edg_wll_Context context, edg_wll_PlainConnection *conn, char **buf, int *code_min)
+get_reply_plain(edg_wll_Context context, edg_wll_PlainConnection *conn, char **buf, int *code_maj, int *code_min)
{
char *msg=NULL;
- int len, code;
+ int len;
struct reader_data data;
data.ctx = context;
data.conn = conn;
- code = 0;
len = read_il_data(&data, &msg, plain_reader);
if(len < 0) {
- edg_wll_SetError(context, LB_PROTO, "get_reply_plain(): error reading message");
+ edg_wll_SetError(context, EDG_WLL_IL_PROTO, "get_reply_plain(): error reading message");
goto get_reply_plain_end;
}
- if(decode_il_reply(&code, code_min, buf, msg) < 0) {
- edg_wll_SetError(context, LB_PROTO, "get_reply_plain(): error decoding message");
+ if(decode_il_reply(code_maj, code_min, buf, msg) < 0) {
+ edg_wll_SetError(context, EDG_WLL_IL_PROTO, "get_reply_plain(): error decoding message");
goto get_reply_plain_end;
}
&len, &gss_code);
if(ret < 0) {
edg_wll_log_proto_handle_gss_failures(data->ctx, ret, &gss_code, "edg_wll_gss_read_full");
- edg_wll_UpdateError(data->ctx, LB_PROTO, "get_reply_gss(): error reading message");
+ edg_wll_UpdateError(data->ctx, EDG_WLL_IL_PROTO, "gss_reader(): error reading message");
}
return(ret);
static
int
-get_reply_gss(edg_wll_Context context, edg_wll_GssConnection *conn, char **buf, int *code_min)
+get_reply_gss(edg_wll_Context context, edg_wll_GssConnection *conn, char **buf, int *code_maj, int *code_min)
{
char *msg = NULL;
int code;
data.conn = conn;
code = read_il_data(&data, &msg, gss_reader);
if(code < 0) {
- edg_wll_SetError(context, LB_PROTO, "get_reply_gss(): error reading reply");
+ edg_wll_SetError(context, EDG_WLL_IL_PROTO, "get_reply_gss(): error reading reply");
goto get_reply_gss_end;
}
- if(decode_il_reply(&code, code_min, buf, msg) < 0) {
- edg_wll_SetError(context, LB_PROTO, "get_reply_gss(): error decoding reply");
+ if(decode_il_reply(code_maj, code_min, buf, msg) < 0) {
+ edg_wll_SetError(context, EDG_WLL_IL_PROTO, "get_reply_gss(): error decoding reply");
goto get_reply_gss_end;
}
static char et[256];
int err;
int code;
+ int lbproto_code;
int count;
errno = err = code = count = 0;
+ lbproto_code = 0;
edg_wll_ResetError(context);
len = encode_il_msg(&buffer, logline);
fprintf(stderr,"log_proto_client_proxy: sending message...\n");
#endif
if (( count = edg_wll_plain_write_full(conn, buffer, len, &context->p_tmp_timeout)) < 0) {
- edg_wll_SetError(context,LB_PROTO,"edg_wll_log_proto_client_proxy(): error sending message to socket");
+ edg_wll_SetError(context, EDG_WLL_IL_PROTO,"edg_wll_log_proto_client_proxy(): error sending message to socket");
goto edg_wll_log_proto_client_proxy_end;
}
#ifdef EDG_WLL_LOG_STUB
fprintf(stderr,"log_proto_client_proxy: reading answer from server...\n");
#endif
- if ((err = get_reply_plain(context, conn, &answer, &code)) < 0 ) {
- edg_wll_SetError(context,LB_PROTO,"edg_wll_log_proto_client_proxy(): error reading answer from L&B Proxy server");
+ if ((err = get_reply_plain(context, conn, &answer, &lbproto_code, &code)) != 0 ) {
+ edg_wll_SetError(context, EDG_WLL_IL_PROTO,"edg_wll_log_proto_client_proxy(): error reading answer from L&B Proxy server");
} else {
#ifdef EDG_WLL_LOG_STUB
- fprintf(stderr,"log_proto_client_proxy: read answer \"%d: %s\"\n",code,answer);
+ fprintf(stderr,"log_proto_client_proxy: read answer \"%d:%d: %s\"\n",lbproto_code,code,answer);
#endif
- snprintf(et, sizeof(et), "answer read from L&B Proxy server: %s", answer);
- edg_wll_SetError(context,code,et);
+ switch (lbproto_code) {
+ case LB_OK: break;
+ case LB_NOMEM:
+ edg_wll_SetError(context, ENOMEM, "edg_wll_log_proto_client_proxy(): proxy out of memory");
+ break;
+ case LB_PROTO:
+ edg_wll_SetError(context, EDG_WLL_IL_PROTO, "edg_wll_log_proto_client_proxy(): received protocol error response");
+ break;
+ case LB_DBERR:
+ snprintf(et, sizeof(et), "error details from L&B Proxy server: %s", answer);
+ edg_wll_SetError(context, code, et);
+ break;
+ default:
+ edg_wll_SetError(context, EDG_WLL_IL_PROTO, "edg_wll_log_proto_client_proxy(): received unknown protocol response");
+ break;
+ }
}
edg_wll_log_proto_client_proxy_end:
char *buffer,*answer = NULL;
static char et[256];
int err;
- int code;
+ int code, lbproto_code;
int count;
edg_wll_GssStatus gss_code;
count = 0;
if (( err = edg_wll_gss_write_full(con, buffer, len, &context->p_tmp_timeout, &count, &gss_code)) < 0) {
edg_wll_log_proto_handle_gss_failures(context,err,&gss_code,"edg_wll_gss_write_full()");
- edg_wll_UpdateError(context,LB_PROTO,"edg_wll_log_proto_client_direct(): error sending message");
+ edg_wll_UpdateError(context, EDG_WLL_IL_PROTO,"edg_wll_log_proto_client_direct(): error sending message");
goto edg_wll_log_proto_client_direct_end;
}
#ifdef EDG_WLL_LOG_STUB
fprintf(stderr,"log_proto_client_direct: reading answer from server...\n");
#endif
- if ((err = get_reply_gss(context, con, &answer, &code)) < 0 ) {
- edg_wll_SetError(context,LB_PROTO,"edg_wll_log_proto_client_direct(): error reading answer from L&B direct server");
+ if ((err = get_reply_gss(context, con, &answer, &lbproto_code, &code)) != 0 ) {
+ edg_wll_SetError(context, EDG_WLL_IL_PROTO,"edg_wll_log_proto_client_direct(): error reading answer from L&B direct server");
} else {
#ifdef EDG_WLL_LOG_STUB
- fprintf(stderr,"log_proto_client_direct: read answer \"%d: %s\"\n",code,answer);
+ fprintf(stderr,"log_proto_client_direct: read answer \"%d:%d: %s\"\n",lbproto_code,code,answer);
#endif
- snprintf(et, sizeof(et), "answer read from bkserver: %s", answer);
- edg_wll_SetError(context,code,et);
+ switch (lbproto_code) {
+ case LB_OK: break;
+ case LB_NOMEM:
+ edg_wll_SetError(context, ENOMEM, "log_proto_client_direct(): server out of memory");
+ break;
+ case LB_PROTO:
+ edg_wll_SetError(context, EDG_WLL_IL_PROTO, "log_proto_client_direct(): received protocol error response");
+ break;
+ case LB_DBERR:
+ snprintf(et, sizeof(et), "error details from L&B server: %s", answer);
+ edg_wll_SetError(context, code, et);
+ break;
+ default:
+ edg_wll_SetError(context, EDG_WLL_IL_PROTO, "log_proto_client_direct(): received unknown protocol response");
+ break;
+ }
}
edg_wll_log_proto_client_direct_end: