@@ -107,7 +107,7 @@ static int create_listening_socket(const char *host, int port)
107
107
setsockopt (s , IPPROTO_TCP , TCP_NODELAY , (char const * )& optval , sizeof (optval ));
108
108
setsockopt (s , SOL_SOCKET , SO_REUSEADDR , (char const * )& optval , sizeof (optval ));
109
109
110
- fprintf ( stderr , "binding tcp %s:%d\n" , host , port );
110
+ elog ( DEBUG1 , "binding tcp %s:%d\n" , host , port );
111
111
if (bind (s , a -> ai_addr , a -> ai_addrlen ) < 0 )
112
112
{
113
113
elog (WARNING , "cannot bind the listening socket: %s" , strerror (errno ));
@@ -133,7 +133,7 @@ static bool add_client(int sock)
133
133
134
134
if (server .clientnum >= MAX_CLIENTS )
135
135
{
136
- fprintf ( stderr , "client limit hit\n" );
136
+ elog ( WARNING , "client limit hit\n" );
137
137
return false;
138
138
}
139
139
@@ -193,17 +193,17 @@ static bool accept_client(void)
193
193
{
194
194
int fd ;
195
195
196
- fprintf ( stderr , "a new connection is queued\n" );
196
+ elog ( DEBUG1 , "a new connection is queued\n" );
197
197
198
198
fd = accept (server .listener , NULL , NULL );
199
199
if (fd == -1 ) {
200
- fprintf ( stderr , "failed to accept a connection: %s\n" , strerror (errno ));
200
+ elog ( WARNING , "failed to accept a connection: %s\n" , strerror (errno ));
201
201
return false;
202
202
}
203
- fprintf ( stderr , "a new connection fd=%d accepted\n" , fd );
203
+ elog ( DEBUG1 , "a new connection fd=%d accepted\n" , fd );
204
204
205
205
if (!raft_is_leader (raft )) {
206
- fprintf ( stderr , "not a leader, disconnecting the accepted connection fd=%d\n" , fd );
206
+ elog ( DEBUG1 , "not a leader, disconnecting the accepted connection fd=%d\n" , fd );
207
207
close (fd );
208
208
return false;
209
209
}
@@ -256,7 +256,6 @@ static void on_message_recv(Client *c)
256
256
key = f -> data ;
257
257
258
258
value = state_get (state , key , & vallen );
259
- fprintf (stderr , "query='%s' answer(%d)='%.*s'\n" , key , (int )vallen , (int )vallen , value );
260
259
answer = make_single_value_message (key , value , vallen , & answersize );
261
260
answer -> meaning = MEAN_OK ;
262
261
if (value ) pfree (value );
@@ -270,7 +269,7 @@ static void on_message_recv(Client *c)
270
269
}
271
270
else
272
271
{
273
- fprintf ( stderr , "unknown meaning %d (%c) of the client's message\n" , rm -> meaning , rm -> meaning );
272
+ elog ( WARNING , "unknown meaning %d (%c) of the client's message\n" , rm -> meaning , rm -> meaning );
274
273
c -> state = CLIENT_SICK ;
275
274
}
276
275
}
@@ -280,7 +279,6 @@ static void on_message_send(Client *c)
280
279
Assert (c -> state == CLIENT_RECVING );
281
280
Assert (c -> msg != NULL );
282
281
Assert (c -> cursor == c -> msg -> len + sizeof (c -> msg -> len ));
283
- fprintf (stderr , "freeing msg = %p\n" , c -> msg );
284
282
pfree (c -> msg );
285
283
c -> msg = NULL ;
286
284
c -> state = CLIENT_SENDING ;
0 commit comments