int main(int argc,char **argv)
{
- int i,njobs,nproc;
+ int i,nproc;
if (argc != 2) {
fprintf(stderr,"usage: %s nproc\n",argv[0]);
if (err == ENOENT) noent++;
+ edg_wll_LogUserTagProxy(ctx,"test","x");
+
edg_wll_FreeContext(ctx);
}
printf("[%d] done, ENOENTs %d\n",pid,noent);
#include "glite/lb/context-int.h"
#include "glite/lb/mini_http.h"
-
+#include "connection.h"
static void CloseConnection(edg_wll_Context ctx, int conn_index)
{
{
edg_wll_plain_close(&ctx->connProxy->conn);
- return edg_wll_Error(ctx, NULL, NULL);
+ return edg_wll_ResetError(ctx);
}
{
struct sockaddr_un saddr;
int flags;
-
+ int err;
+ char *ed = NULL;
+ int retries = 0;
if (ctx->connProxy->conn.sock > -1) {
// XXX: test path socket here?
goto err;
}
- if (connect(ctx->connProxy->conn.sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
- edg_wll_SetError(ctx, errno, "connect()");
+ while ((err = connect(ctx->connProxy->conn.sock, (struct sockaddr *)&saddr, sizeof(saddr))) < 0 &&
+ errno == EAGAIN &&
+ ctx->p_tmp_timeout.tv_sec >= 0 && ctx->p_tmp_timeout.tv_usec >= 0 &&
+ !(ctx->p_tmp_timeout.tv_sec == 0 && ctx->p_tmp_timeout.tv_usec == 0)
+ )
+ {
+ struct timespec ns = { 0, PROXY_CONNECT_RETRY * 1000000 /* 10 ms */ },rem;
+
+ nanosleep(&ns,&rem);
+
+ ctx->p_tmp_timeout.tv_usec -= ns.tv_nsec/1000;
+ ctx->p_tmp_timeout.tv_usec += rem.tv_nsec/1000;
+
+ ctx->p_tmp_timeout.tv_sec -= ns.tv_sec;
+ ctx->p_tmp_timeout.tv_sec += rem.tv_sec;
+
+ if (ctx->p_tmp_timeout.tv_usec < 0) {
+ ctx->p_tmp_timeout.tv_usec += 1000000;
+ ctx->p_tmp_timeout.tv_sec--;
+ }
+ retries++;
+ }
+
+ /* printf("retries %d\n",retries); */
+
+ if (err) {
+ if (errno == EAGAIN) edg_wll_SetError(ctx,ETIMEDOUT, "edg_wll_open_proxy()");
+ else edg_wll_SetError(ctx, errno, "connect()");
goto err;
}
- return edg_wll_Error(ctx,NULL,NULL);
+ return edg_wll_ResetError(ctx);
err:
/* some error occured; close created connection */
+ err = edg_wll_Error(ctx,NULL,&ed);
edg_wll_close_proxy(ctx);
+ edg_wll_SetError(ctx,err,ed);
+ free(ed);
- return edg_wll_Error(ctx,NULL,NULL);
+ return err;
}
#ifndef __EDG_WORKLOAD_LOGGING_CLIENT_CONNECTION_H__
#define __EDG_WORKLOAD_LOGGING_CLIENT_CONNECTION_H__
-#ident "$Header"
+#ident "$Header$"
int edg_wll_close(edg_wll_Context ctx);
int edg_wll_open(edg_wll_Context ctx);
int http_check_status(edg_wll_Context, char *);
+#define PROXY_CONNECT_RETRY 10 /* ms */
+
#endif /* __EDG_WORKLOAD_LOGGING_CLIENT_CONNECTION_H__ */
#include "glite/lb/escape.h"
#include "prod_proto.h"
+#include "connection.h"
static const char* socket_path="/tmp/lb_proxy_store.sock";
edg_wll_LogLine logline)
{
int answer;
- int flags;
+ int flags,retries;
char *name_esc,*dguser;
struct sockaddr_un saddr;
edg_wll_PlainConnection conn;
close(conn.sock);
goto edg_wll_DoLogEventProxy_end;
}
+
+/* non-retry variant (pre bug #18994)
+ * XXX: what is the EISCONN case good for? conn.sock is created above.
+ *
if (connect(conn.sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
if(errno != EISCONN) {
edg_wll_SetError(context,answer = errno,"connect()");
goto edg_wll_DoLogEventProxy_end;
}
}
+*/
+
+ retries = 0;
+ while ((answer = connect(conn.sock, (struct sockaddr *)&saddr, sizeof(saddr))) < 0 &&
+ errno == EAGAIN &&
+ context->p_tmp_timeout.tv_sec >= 0 && context->p_tmp_timeout.tv_usec >= 0 &&
+ !(context->p_tmp_timeout.tv_sec == 0 && context->p_tmp_timeout.tv_usec == 0)
+ )
+ {
+ struct timespec ns = { 0, PROXY_CONNECT_RETRY * 1000000 /* 10 ms */ },rem;
+
+ nanosleep(&ns,&rem);
+
+ context->p_tmp_timeout.tv_usec -= ns.tv_nsec/1000;
+ context->p_tmp_timeout.tv_usec += rem.tv_nsec/1000;
+
+ context->p_tmp_timeout.tv_sec -= ns.tv_sec;
+ context->p_tmp_timeout.tv_sec += rem.tv_sec;
+
+ if (context->p_tmp_timeout.tv_usec < 0) {
+ context->p_tmp_timeout.tv_usec += 1000000;
+ context->p_tmp_timeout.tv_sec--;
+ }
+ retries++;
+ }
+
+ if (answer) {
+ if (errno == EAGAIN) edg_wll_SetError(context,answer = ETIMEDOUT,"edg_wll_DoLogEventProxy connect()");
+ else edg_wll_SetError(context,answer = errno,"connect()");
+ close(conn.sock);
+ goto edg_wll_DoLogEventProxy_end;
+ }
+
+/* just debug if (retries) printf("edg_wll_DoLogEventProxy connect retries %d\n",retries); */
/* add DG.USER to the message: */
name_esc = edg_wll_LogEscape(context->p_user_lbproxy);