Răsfoiți Sursa

Compiler warnings and paged results on DSE
1) Fixing compiler warnings on regex.c.
2) Adding dse_search_set_release to dse.c to support simple paged results on DSE.

Noriko Hosoi 16 ani în urmă
părinte
comite
dacd95700c

+ 1 - 0
ldap/servers/slapd/backend_manager.c

@@ -138,6 +138,7 @@ be_new_internal(struct dse *pdse, const char *type, const char *name)
     be->be_database->plg_unbind= &dse_unbind;
     be->be_database->plg_search= &dse_search;
     be->be_database->plg_next_search_entry= &dse_next_search_entry;
+    be->be_database->plg_search_results_release= &dse_search_set_release;
     be->be_database->plg_compare= &be_plgfn_unwillingtoperform;
     be->be_database->plg_modify= &dse_modify;
     be->be_database->plg_modrdn= &be_plgfn_unwillingtoperform;

+ 3 - 1
ldap/servers/slapd/connection.c

@@ -199,7 +199,9 @@ connection_cleanup(Connection *conn)
 	sasl_dispose((sasl_conn_t**)&conn->c_sasl_conn);
 	/* PAGED_RESULTS */
 	if (conn->c_search_result_set) {
-		conn->c_current_be->be_search_results_release(&(conn->c_search_result_set));
+		if (conn->c_current_be->be_search_results_release) {
+			conn->c_current_be->be_search_results_release(&(conn->c_search_result_set));
+		}
 		conn->c_search_result_set = NULL;
 	}
 	conn->c_current_be = NULL;

+ 6 - 0
ldap/servers/slapd/dse.c

@@ -2305,6 +2305,12 @@ dse_search_set_clean(dse_search_set *ss)
 	}
 }
 
+void 
+dse_search_set_release (void **ss)
+{
+	dse_search_set_delete(*(dse_search_set **)ss);
+}
+
 static void 
 dse_search_set_delete (dse_search_set *ss)
 {

+ 8 - 3
ldap/servers/slapd/opshared.c

@@ -500,9 +500,9 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
   if (operation->o_flags & OP_FLAG_PAGED_RESULTS) {
     time_t optime, time_up;
     int tlimit;
-	slapi_pblock_get( pb, SLAPI_SEARCH_TIMELIMIT, &tlimit );
-	slapi_pblock_get( pb, SLAPI_OPINITIATED_TIME, &optime );
-	time_up = (tlimit==-1 ? -1 : optime + tlimit); /* -1: no time limit */
+    slapi_pblock_get( pb, SLAPI_SEARCH_TIMELIMIT, &tlimit );
+    slapi_pblock_get( pb, SLAPI_OPINITIATED_TIME, &optime );
+    time_up = (tlimit==-1 ? -1 : optime + tlimit); /* -1: no time limit */
     pagedresults_set_timelimit(pb->pb_conn, time_up);
   }
 
@@ -555,10 +555,15 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
     }
         
     if ((operation->o_flags & OP_FLAG_PAGED_RESULTS) && pr_search_result) {
+      void *sr = NULL;
       /* PAGED RESULTS and already have the search results from the prev op */
       slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, pr_search_result );
       rc = send_results_ext (pb, 1, &pnentries, pagesize, &pr_stat);
 
+      /* search result could be reset in the backend/dse */
+      slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET, &sr);
+      pagedresults_set_search_result(pb->pb_conn, sr);
+
       if (PAGEDRESULTS_SEARCH_END == pr_stat) {
         /* no more entries to send in the backend */
         if (NULL == next_be) {

+ 2 - 0
ldap/servers/slapd/proto-slap.h

@@ -603,6 +603,8 @@ void dse_set_dont_ever_write_dse_files(void);
 void dse_unset_dont_ever_write_dse_files(void);
 int dse_next_search_entry (Slapi_PBlock *pb);
 char *dse_read_next_entry( char *buf, char **lastp );
+void dse_search_set_release (void **ss);
+
 
 
 /*

+ 7 - 7
ldap/servers/slapd/regex.c

@@ -61,7 +61,7 @@ struct slapi_regex_handle {
  * \warning The regex handler should be released by slapi_re_free().
  */
 Slapi_Regex *
-slapi_re_comp( char *pat, char **error )
+slapi_re_comp( const char *pat, const char **error )
 {
     Slapi_Regex *re_handle = NULL;
     pcre        *re = NULL;
@@ -94,7 +94,7 @@ slapi_re_comp( char *pat, char **error )
  * \warning The regex handler should be released by slapi_re_free().
  */
 int
-slapi_re_exec( Slapi_Regex *re_handle, char *subject, time_t time_up )
+slapi_re_exec( Slapi_Regex *re_handle, const char *subject, time_t time_up )
 {
     int rc;
     time_t curtime = current_time();
@@ -143,16 +143,16 @@ slapi_re_exec( Slapi_Regex *re_handle, char *subject, time_t time_up )
  * \warning The regex handler should be released by slapi_re_free().
  */
 int
-slapi_re_subs( Slapi_Regex *re_handle,
-               char *subject, char *src, char **dst, unsigned long dstlen )
+slapi_re_subs( Slapi_Regex *re_handle, const char *subject,
+               const char *src, char **dst, unsigned long dstlen )
 {
     int  thislen = 0;
     int  len = 0;
     int  pin;
     int  *ovector;
     char *mydst = *dst;
-    char *substring_start;
-    char *p;
+    const char *substring_start;
+    const char *p;
 
     if (NULL == src || NULL == re_handle || NULL == re_handle->re_ovector) {
         memset(*dst, '\0', dstlen);
@@ -163,7 +163,7 @@ slapi_re_subs( Slapi_Regex *re_handle,
 
     ovector = re_handle->re_ovector;
 
-    for (p = src; *p != NULL; p++) {
+    for (p = src; *p != '\0'; p++) {
         if ('&' == *p) {
             if (re_handle->re_oveccount <= 1) {
                 memset(*dst, '\0', dstlen);

+ 3 - 3
ldap/servers/slapd/slapi-plugin.h

@@ -3364,7 +3364,7 @@ typedef struct slapi_regex_handle Slapi_Regex;
  * the compiled pattern. NULL if the compile fails.
  * \warning The regex handler should be released by slapi_re_free().
  */
-Slapi_Regex *slapi_re_comp( char *pat, char **error );
+Slapi_Regex *slapi_re_comp( const char *pat, const char **error );
 /**
  * Matches a compiled regular expression pattern against a given string.
  * A thin wrapper of pcre_exec.
@@ -3378,7 +3378,7 @@ Slapi_Regex *slapi_re_comp( char *pat, char **error );
  * \return This function returns other values if any error occurred.
  * \warning The regex handler should be released by slapi_re_free().
  */
-int slapi_re_exec( Slapi_Regex *re_handle, char *subject, time_t time_up );
+int slapi_re_exec( Slapi_Regex *re_handle, const char *subject, time_t time_up );
 /**
  * Substitutes '&' or '\#' in the param src with the matched string.
  *
@@ -3391,7 +3391,7 @@ int slapi_re_exec( Slapi_Regex *re_handle, char *subject, time_t time_up );
  * \return This function returns 0 if the substitution failed.
  * \warning The regex handler should be released by slapi_re_free().
  */
-int slapi_re_subs( Slapi_Regex *re_handle, char *subject, char *src, char **dst, unsigned long dstlen );
+int slapi_re_subs( Slapi_Regex *re_handle, const char *subject, const char *src, char **dst, unsigned long dstlen );
 /**
  * Releases the regex handler which was returned from slapi_re_comp.
  *