aboutsummaryrefslogtreecommitdiffstats
path: root/src/gnutls.c
diff options
context:
space:
mode:
authorPaul Eggert2012-04-09 15:54:59 -0700
committerPaul Eggert2012-04-09 15:54:59 -0700
commit45e9f7da84c1bd3fc0d36d05c5708ed3b2d3a193 (patch)
tree5bc87a8b5a3c754b8eb44a612cc6c03561d6b968 /src/gnutls.c
parent9d6b4d53469a9ffd67bd770fabc6fe254e35c21d (diff)
parent05920a43fc18e696b464387e781e7cfdcea5b5af (diff)
downloademacs-45e9f7da84c1bd3fc0d36d05c5708ed3b2d3a193.tar.gz
emacs-45e9f7da84c1bd3fc0d36d05c5708ed3b2d3a193.zip
Merge from trunk.
Diffstat (limited to 'src/gnutls.c')
-rw-r--r--src/gnutls.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/gnutls.c b/src/gnutls.c
index 99fc5c10e2b..8dbf01cedc9 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -247,18 +247,27 @@ init_gnutls_functions (Lisp_Object libraries)
247#endif /* !WINDOWSNT */ 247#endif /* !WINDOWSNT */
248 248
249 249
250/* Function to log a simple message. */
250static void 251static void
251gnutls_log_function (int level, const char* string) 252gnutls_log_function (int level, const char* string)
252{ 253{
253 message ("gnutls.c: [%d] %s", level, string); 254 message ("gnutls.c: [%d] %s", level, string);
254} 255}
255 256
257/* Function to log a message and a string. */
256static void 258static void
257gnutls_log_function2 (int level, const char* string, const char* extra) 259gnutls_log_function2 (int level, const char* string, const char* extra)
258{ 260{
259 message ("gnutls.c: [%d] %s %s", level, string, extra); 261 message ("gnutls.c: [%d] %s %s", level, string, extra);
260} 262}
261 263
264/* Function to log a message and an integer. */
265static void
266gnutls_log_function2i (int level, const char* string, int extra)
267{
268 message ("gnutls.c: [%d] %s %d", level, string, extra);
269}
270
262static int 271static int
263emacs_gnutls_handshake (struct Lisp_Process *proc) 272emacs_gnutls_handshake (struct Lisp_Process *proc)
264{ 273{
@@ -399,10 +408,25 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte)
399 ssize_t rtnval; 408 ssize_t rtnval;
400 gnutls_session_t state = proc->gnutls_state; 409 gnutls_session_t state = proc->gnutls_state;
401 410
411 int log_level = proc->gnutls_log_level;
412
402 if (proc->gnutls_initstage != GNUTLS_STAGE_READY) 413 if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
403 { 414 {
404 emacs_gnutls_handshake (proc); 415 /* If the handshake count is under the limit, try the handshake
405 return -1; 416 again and increment the handshake count. This count is kept
417 per process (connection), not globally. */
418 if (proc->gnutls_handshakes_tried < GNUTLS_EMACS_HANDSHAKES_LIMIT)
419 {
420 proc->gnutls_handshakes_tried++;
421 emacs_gnutls_handshake (proc);
422 GNUTLS_LOG2i (5, log_level, "Retried handshake",
423 proc->gnutls_handshakes_tried);
424 return -1;
425 }
426
427 GNUTLS_LOG (2, log_level, "Giving up on handshake; resetting retries");
428 proc->gnutls_handshakes_tried = 0;
429 return 0;
406 } 430 }
407 rtnval = fn_gnutls_record_recv (state, buf, nbyte); 431 rtnval = fn_gnutls_record_recv (state, buf, nbyte);
408 if (rtnval >= 0) 432 if (rtnval >= 0)