Browse Source

Bugfix in logger ident update + deleted debug logging

Yann Weber 4 years ago
parent
commit
9e413450a9
5 changed files with 15 additions and 8 deletions
  1. 4
    1
      include/conf.h
  2. 3
    3
      src/conf.c
  3. 7
    2
      src/logger.c
  4. 0
    2
      src/pyutils.c
  5. 1
    0
      src/responder.c

+ 4
- 1
include/conf.h View File

@@ -113,10 +113,10 @@ typedef struct pyfcgi_conf_s pyfcgi_conf_t;
113 113
 typedef struct pyfcgi_conf_logger_s pyfcgi_conf_logger_t;
114 114
 typedef struct pyfcgi_context_s pyfcgi_context_t;
115 115
 
116
+/**@brief Stores contextual informations about current process */
116 117
 struct pyfcgi_context_s {
117 118
 	pid_t pid;
118 119
 	pid_t ppid;
119
-	char *pidfile;
120 120
 };
121 121
 
122 122
 /**@brief Structure containing configuration
@@ -126,6 +126,9 @@ struct pyfcgi_context_s {
126 126
  */
127 127
 struct pyfcgi_conf_s
128 128
 {
129
+	/** @brief Stores pidfile path */
130
+	char *pidfile;
131
+
129 132
 	/**@brief Entrypoint module name
130 133
 	 * @ingroup conf_glob */
131 134
 	char *py_entrymod;

+ 3
- 3
src/conf.c View File

@@ -99,7 +99,8 @@ int parse_args(int argc, char *argv[])
99 99
 				pyfcgi_logger_enable_syslog(ident);
100 100
 				break;
101 101
 			case 'P':
102
-				PyFCGI_conf.context.pidfile = strdup(optarg);
102
+				PyFCGI_conf.pidfile = strdup(optarg);
103
+				/**@todo create pidfile and put master pid in it */
103 104
 				break;
104 105
 			case 'h':
105 106
 				usage();
@@ -145,7 +146,6 @@ int check_entrypoint_import()
145 146
 	pid = fork();
146 147
 	if(!pid)
147 148
 	{
148
-		pyfcgi_log(LOG_DEBUG, "Checking entrypoint import");
149 149
 		pyinit();
150 150
 		ret = (void*)import_entrypoint();
151 151
 		if(!ret)
@@ -153,7 +153,7 @@ int check_entrypoint_import()
153 153
 			dprintf(2, "Unable to import entrypoint...\n");
154 154
 			exit(1);
155 155
 		}
156
-		pyfcgi_log(LOG_DEBUG, "Entrypoint import OK");
156
+		pyfcgi_log(LOG_DEBUG, "Entrypoint import [OK]");
157 157
 		Py_Exit(0);
158 158
 	}
159 159
 	waitpid(pid, &status, 0);

+ 7
- 2
src/logger.c View File

@@ -247,6 +247,11 @@ int pyfcgi_logger_format_bufinit(pyfcgi_logger_format_t* fmt)
247 247
 	{ // if it is not the first call
248 248
 		free(fmt->buf);
249 249
 	}
250
+	if(fmt->_msg)
251
+	{ // delete message buffer to force prefix copy
252
+		free(fmt->_msg);
253
+		fmt->_msg = NULL;
254
+	}
250 255
 
251 256
 	i = 0;
252 257
 	pre_sz = 0;
@@ -574,7 +579,7 @@ int pyfcgi_logger_set_ident(const char* new_ident)
574 579
 		pyfcgi_logger_enable_syslog(new_ident);
575 580
 	}
576 581
 
577
-	len = strlen(new_ident);
582
+	len = strlen(conf->ident);
578 583
 	for(i=0; i<conf->format_sz; i++)
579 584
 	{
580 585
 		fmt = &(conf->formats[i]);
@@ -622,7 +627,7 @@ char* vpyfcgi_logger_format_message(pyfcgi_logger_format_t *fmt,
622 627
 		if(!fmt->_msg)
623 628
 		{
624 629
 			//TODO : error
625
-dprintf(2, "ERROR ALLOC _msg : %s", strerror(errno));
630
+dprintf(2, "ERROR ALLOC _msg : %s\n", strerror(errno));
626 631
 			return NULL;
627 632
 		}
628 633
 		memset(fmt->_msg, ' ', sizeof(char)*fmt->_msglen);

+ 0
- 2
src/pyutils.c View File

@@ -57,9 +57,7 @@ void update_python_path()
57 57
 	}
58 58
 
59 59
 	// Fetch, dup & update the python path
60
-pyfcgi_log(LOG_DEBUG, "DEBUG 0");
61 60
 	ppath = Py_GetPath();
62
-pyfcgi_log(LOG_DEBUG, "DEBUG 1");
63 61
 	if(!ppath)
64 62
 	{
65 63
 		if(PyErr_Occurred())

+ 1
- 0
src/responder.c View File

@@ -43,6 +43,7 @@ int responder_loop()
43 43
 	timeout.tv_nsec = 100000000;
44 44
 	idle = 0;
45 45
 
46
+	pyfcgi_logger_set_ident("pool");
46 47
 	pyfcgi_log(LOG_INFO, "Preparing workers");
47 48
 
48 49
 	init_context();

Loading…
Cancel
Save