375 } |
375 } |
376 |
376 |
377 connection->keep_alive_source = NULL; |
377 connection->keep_alive_source = NULL; |
378 } |
378 } |
379 |
379 |
380 static gboolean |
380 static void |
381 connection_send (LmConnection *connection, |
381 connection_log_send (LmConnection *connection, |
382 const gchar *str, |
382 const gchar *str, |
383 gint len, |
383 gint len) |
384 GError **error) |
384 { |
385 { |
|
386 gint b_written; |
|
387 |
|
388 if (connection->state < LM_CONNECTION_STATE_OPENING) { |
|
389 g_log (LM_LOG_DOMAIN,LM_LOG_LEVEL_NET, |
|
390 "Connection is not open.\n"); |
|
391 |
|
392 g_set_error (error, |
|
393 LM_ERROR, |
|
394 LM_ERROR_CONNECTION_NOT_OPEN, |
|
395 "Connection is not open, call lm_connection_open() first"); |
|
396 return FALSE; |
|
397 } |
|
398 |
|
399 if (len == -1) { |
|
400 len = strlen (str); |
|
401 } |
|
402 |
|
403 g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "\nSEND:\n"); |
385 g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "\nSEND:\n"); |
404 g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, |
386 g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, |
405 "-----------------------------------\n"); |
387 "-----------------------------------\n"); |
406 g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "%s\n", str); |
388 g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "%s\n", str); |
407 g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, |
389 g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, |
408 "-----------------------------------\n"); |
390 "-----------------------------------\n"); |
|
391 } |
|
392 |
|
393 static gboolean |
|
394 connection_send (LmConnection *connection, |
|
395 const gchar *str, |
|
396 gint len, |
|
397 GError **error) |
|
398 { |
|
399 gint b_written; |
|
400 |
|
401 if (connection->state < LM_CONNECTION_STATE_OPENING) { |
|
402 g_log (LM_LOG_DOMAIN,LM_LOG_LEVEL_NET, |
|
403 "Connection is not open.\n"); |
|
404 |
|
405 g_set_error (error, |
|
406 LM_ERROR, |
|
407 LM_ERROR_CONNECTION_NOT_OPEN, |
|
408 "Connection is not open, call lm_connection_open() first"); |
|
409 return FALSE; |
|
410 } |
|
411 |
|
412 if (len == -1) { |
|
413 len = strlen (str); |
|
414 } |
|
415 |
|
416 connection_log_send (connection, str, len); |
409 |
417 |
410 /* Check to see if there already is an output buffer, if so, add to the |
418 /* Check to see if there already is an output buffer, if so, add to the |
411 buffer and return */ |
419 buffer and return */ |
412 |
420 |
413 if (lm_socket_output_is_buffered (connection->socket, str, len)) { |
421 if (lm_socket_output_is_buffered (connection->socket, str, len)) { |