~ubuntu-branches/ubuntu/wily/openldap/wily

« back to all changes in this revision

Viewing changes to debian/patches/its-7176-only-poll-sockets-for-write-as-needed.diff

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-02-21 15:36:29 UTC
  • Revision ID: package-import@ubuntu.com-20120221153629-mafzox069h751lsp
Tags: 2.4.28-1.1ubuntu3
Add its-7176-only-poll-sockets-for-write-as-needed.diff
(LP: #932823).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 33f6bc4fe623a2fdef02de1a84fdb93de1aad32a Mon Sep 17 00:00:00 2001
 
2
From: Howard Chu <hyc@openldap.org>
 
3
Date: Mon, 20 Feb 2012 14:51:30 -0800
 
4
Subject: [PATCH] ITS#7167 only poll sockets for write as needed
 
5
 
 
6
---
 
7
 libraries/libldap/ldap-int.h |    1 +
 
8
 libraries/libldap/open.c     |    2 --
 
9
 libraries/libldap/os-ip.c    |   26 ++++++++++++++++++++++++++
 
10
 libraries/libldap/request.c  |    1 +
 
11
 libraries/libldap/result.c   |    6 +++---
 
12
 5 files changed, 31 insertions(+), 5 deletions(-)
 
13
 
 
14
diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h
 
15
index c558d2a..ad37250 100644
 
16
--- a/libraries/libldap/ldap-int.h
 
17
+++ b/libraries/libldap/ldap-int.h
 
18
@@ -622,6 +622,7 @@ LDAP_F (void) ldap_free_select_info( void *sip );
 
19
 LDAP_F (void) ldap_mark_select_write( LDAP *ld, Sockbuf *sb );
 
20
 LDAP_F (void) ldap_mark_select_read( LDAP *ld, Sockbuf *sb );
 
21
 LDAP_F (void) ldap_mark_select_clear( LDAP *ld, Sockbuf *sb );
 
22
+LDAP_F (void) ldap_clear_select_write( LDAP *ld, Sockbuf *sb );
 
23
 LDAP_F (int) ldap_is_read_ready( LDAP *ld, Sockbuf *sb );
 
24
 LDAP_F (int) ldap_is_write_ready( LDAP *ld, Sockbuf *sb );
 
25
 
 
26
diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c
 
27
index 6b92ba6..a920953 100644
 
28
--- a/libraries/libldap/open.c
 
29
+++ b/libraries/libldap/open.c
 
30
@@ -344,7 +344,6 @@ ldap_init_fd(
 
31
 
 
32
        /* Add the connection to the *LDAP's select pool */
 
33
        ldap_mark_select_read( ld, conn->lconn_sb );
 
34
-       ldap_mark_select_write( ld, conn->lconn_sb );
 
35
        
 
36
        *ldp = ld;
 
37
        return LDAP_SUCCESS;
 
38
@@ -502,7 +501,6 @@ ldap_open_internal_connection( LDAP **ldp, ber_socket_t *fdp )
 
39
 
 
40
        /* Add the connection to the *LDAP's select pool */
 
41
        ldap_mark_select_read( ld, c->lconn_sb );
 
42
-       ldap_mark_select_write( ld, c->lconn_sb );
 
43
 
 
44
        /* Make this connection an LDAP V3 protocol connection */
 
45
        rc = LDAP_VERSION3;
 
46
diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c
 
47
index daa765e..2864256 100644
 
48
--- a/libraries/libldap/os-ip.c
 
49
+++ b/libraries/libldap/os-ip.c
 
50
@@ -966,6 +966,32 @@ ldap_mark_select_clear( LDAP *ld, Sockbuf *sb )
 
51
 #endif
 
52
 }
 
53
 
 
54
+void
 
55
+ldap_clear_select_write( LDAP *ld, Sockbuf *sb )
 
56
+{
 
57
+       struct selectinfo       *sip;
 
58
+       ber_socket_t            sd;
 
59
+
 
60
+       sip = (struct selectinfo *)ld->ld_selectinfo;
 
61
+
 
62
+       ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd );
 
63
+
 
64
+#ifdef HAVE_POLL
 
65
+       /* for UNIX poll(2) */
 
66
+       {
 
67
+               int i;
 
68
+               for(i=0; i < sip->si_maxfd; i++) {
 
69
+                       if( sip->si_fds[i].fd == sd ) {
 
70
+                               sip->si_fds[i].events &= ~POLL_WRITE;
 
71
+                       }
 
72
+               }
 
73
+       }
 
74
+#else
 
75
+       /* for UNIX select(2) */
 
76
+       FD_CLR( sd, &sip->si_writefds );
 
77
+#endif
 
78
+}
 
79
+
 
80
 
 
81
 int
 
82
 ldap_is_write_ready( LDAP *ld, Sockbuf *sb )
 
83
diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c
 
84
index 88190a2..071391d 100644
 
85
--- a/libraries/libldap/request.c
 
86
+++ b/libraries/libldap/request.c
 
87
@@ -202,6 +202,7 @@ ldap_int_flush_request(
 
88
 
 
89
                /* sent -- waiting for a response */
 
90
                ldap_mark_select_read( ld, lc->lconn_sb );
 
91
+               ldap_clear_select_write( ld, lc->lconn_sb );
 
92
        }
 
93
        return 0;
 
94
 }
 
95
diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c
 
96
index b6e8e75..7241df9 100644
 
97
--- a/libraries/libldap/result.c
 
98
+++ b/libraries/libldap/result.c
 
99
@@ -302,7 +302,7 @@ wait4msg(
 
100
                                if ( ber_sockbuf_ctrl( lc->lconn_sb,
 
101
                                        LBER_SB_OPT_DATA_READY, NULL ) )
 
102
                                {
 
103
-                                       lc_ready = 1;
 
104
+                                       lc_ready = 2;   /* ready at ber level, not socket level */
 
105
                                        break;
 
106
                                }
 
107
                        }
 
108
@@ -373,8 +373,8 @@ wait4msg(
 
109
                                        }
 
110
                                }
 
111
                                LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
 
112
-                               /* Quit looping if no one handled any events */
 
113
-                               if (!serviced)
 
114
+                               /* Quit looping if no one handled any socket events */
 
115
+                               if (!serviced && lc_ready == 1)
 
116
                                        rc = -1;
 
117
                        }
 
118
                        LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
 
119
-- 
 
120
1.7.4.2
 
121