Fixed bugs introduced while moving to krb5 repository
authorAlexandra Ellwood <lxs@mit.edu>
Mon, 4 Jun 2007 22:24:27 +0000 (22:24 +0000)
committerAlexandra Ellwood <lxs@mit.edu>
Mon, 4 Jun 2007 22:24:27 +0000 (22:24 +0000)
Fixed memory leak in ccs_ccache_t and ccs_cache_collection_t when returning
the reply data.  Changed to "will_block" semantics for flow control in all
server function so it doesn't get confusing.  Fixed bug in
ccs_server_send_reply() which was preventing ipc from working (was using
the wrong variable for the reply stream).

ticket:new

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19567 dc483132-0cff-0310-8789-dd5450dbe970

src/ccapi/server/ccs_cache_collection.c
src/ccapi/server/ccs_ccache.c
src/ccapi/server/ccs_lock_state.c
src/ccapi/server/ccs_server.c

index 4927aaacb7bfbeadc85d8b9559318b355f203e76..44cf5a8824d3c3ac4df028f176f5c3794eb3b556 100644 (file)
@@ -939,8 +939,12 @@ static cc_int32 ccs_cache_collection_unlock (ccs_pipe_t             in_client_pi
     
     if (!err) {
         *out_will_block = will_block;
-        *out_reply_data = reply_data;
-        reply_data = NULL; /* take ownership */
+        if (!will_block) {
+            *out_reply_data = reply_data;
+            reply_data = NULL; /* take ownership */
+        } else {
+            *out_reply_data = NULL;
+        }
     }
     
     cci_stream_release (reply_data);
index aaeed979658a5c5e98588ccb3a5b7de920a5f944..dfe66863384eb165afd328bdebc715dded95d726 100644 (file)
@@ -991,8 +991,12 @@ cc_int32 ccs_ccache_handle_message (ccs_pipe_t              in_client_pipe,
     
     if (!err) {
         *out_will_block = will_block;
-        *out_reply_data = reply_data;
-        reply_data = NULL; /* take ownership */
+        if (!will_block) {
+            *out_reply_data = reply_data;
+            reply_data = NULL; /* take ownership */
+        } else {
+            *out_reply_data = NULL;
+        }
     }
     
     cci_stream_release (reply_data);
index f9bb614c2862fa4d784c961f94a1ebcef683db6b..6276306bc33ca1bafb2b888e36b7f6ceadcfad05 100644 (file)
@@ -81,7 +81,7 @@ cc_int32 ccs_lock_state_release (ccs_lock_state_t io_lock_state)
 {
     cc_int32 err = ccNoError;
     
-    if (!io_lock_state) { err = cci_check_error (ccErrBadParam); }
+    if (!io_lock_state) { err = ccErrBadParam; }
 
     if (!err) {
         ccs_lock_array_release (io_lock_state->locks);
index b7d3be4b1c5ed3093ee401bd5e1b1944a0c01ecd..6f8fffe6531e190ef6b041b63964bb687abcbaf9 100644 (file)
@@ -144,14 +144,14 @@ static cc_int32 ccs_server_request_demux (ccs_pipe_t              in_client_pipe
                                           enum cci_msg_id_t       in_request_name,
                                           cci_identifier_t        in_request_identifier,
                                           cci_stream_t            in_request_data,
-                                          cc_uint32              *out_reply_immediately,
+                                          cc_uint32              *out_will_block,
                                           cci_stream_t           *out_reply_data)
 {
     cc_int32 err = ccNoError;
 
     if (!ccs_pipe_valid (in_reply_pipe)) { err = cci_check_error (ccErrBadParam); }
     if (!in_request_data               ) { err = cci_check_error (ccErrBadParam); }
-    if (!out_reply_immediately         ) { err = cci_check_error (ccErrBadParam); }
+    if (!out_will_block                ) { err = cci_check_error (ccErrBadParam); }
     if (!out_reply_data                ) { err = cci_check_error (ccErrBadParam); }
 
     if (!err) {
@@ -166,7 +166,7 @@ static cc_int32 ccs_server_request_demux (ccs_pipe_t              in_client_pipe
                                                            in_cache_collection,
                                                            in_request_name,
                                                            in_request_data,
-                                                           out_reply_immediately,
+                                                           out_will_block,
                                                            out_reply_data);
             }
                 
@@ -185,7 +185,7 @@ static cc_int32 ccs_server_request_demux (ccs_pipe_t              in_client_pipe
                                                  in_cache_collection,
                                                  in_request_name,
                                                  in_request_data,
-                                                 out_reply_immediately,
+                                                 out_will_block,
                                                  out_reply_data);
             }                
                         
@@ -206,7 +206,7 @@ static cc_int32 ccs_server_request_demux (ccs_pipe_t              in_client_pipe
             }
             
             if (!err) {
-                *out_reply_immediately = 1; /* can't block */
+                *out_will_block = 0; /* can't block */
             }
             
         } else if (in_request_name > cci_credentials_iterator_first_msg_id &&
@@ -228,7 +228,7 @@ static cc_int32 ccs_server_request_demux (ccs_pipe_t              in_client_pipe
             }
             
             if (!err) {
-                *out_reply_immediately = 1; /* can't block */
+                *out_will_block = 0; /* can't block */
             }
  
         } else {
@@ -250,7 +250,7 @@ cc_int32 ccs_server_handle_request (ccs_pipe_t     in_client_pipe,
     cc_int32 err = ccNoError;
     enum cci_msg_id_t request_name = 0;
     cci_identifier_t request_identifier = NULL;
-    cc_uint32 reply_immediately = 1;
+    cc_uint32 will_block = 0;
     cci_stream_t reply_data = NULL;
     
     if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); }
@@ -288,16 +288,19 @@ cc_int32 ccs_server_handle_request (ccs_pipe_t     in_client_pipe,
                                                    request_name,
                                                    request_identifier,
                                                    in_request, 
-                                                   &reply_immediately,
+                                                   &will_block,
                                                    &reply_data);
         }
         
-        if (server_err || reply_immediately) {
+        if (server_err || !will_block) {
+
+            /* send a reply now if the server isn't blocked on something */
             err = ccs_server_send_reply (in_reply_pipe, server_err, reply_data);
         }
     }
 
     cci_identifier_release (request_identifier);
+    cci_stream_release (reply_data);
     
     return cci_check_error (err);    
 }
@@ -318,7 +321,7 @@ cc_int32 ccs_server_send_reply (ccs_pipe_t     in_reply_pipe,
     }
     
     if (!err && in_reply_data && cci_stream_size (in_reply_data) > 0) {
-        err = cci_stream_write (in_reply_data
+        err = cci_stream_write (reply
                                 cci_stream_data (in_reply_data), 
                                 cci_stream_size (in_reply_data));
     }