Limit range of lock timeouts/intervals.

Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/f391174c
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/f391174c
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/f391174c

Branch: refs/heads/master
Commit: f391174cd33ba98e989ada7bc61e93c5c0576cc6
Parents: 679ced9
Author: Marvin Humphrey <mar...@rectangular.com>
Authored: Thu May 5 19:14:08 2016 -0700
Committer: Marvin Humphrey <mar...@rectangular.com>
Committed: Fri May 6 18:28:21 2016 -0700

----------------------------------------------------------------------
 core/Lucy/Index/IndexManager.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/f391174c/core/Lucy/Index/IndexManager.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/IndexManager.c b/core/Lucy/Index/IndexManager.c
index 15425e9..8bc80fe 100644
--- a/core/Lucy/Index/IndexManager.c
+++ b/core/Lucy/Index/IndexManager.c
@@ -237,8 +237,8 @@ IxManager_Make_Write_Lock_IMP(IndexManager *self) {
     String *write_lock_name = SSTR_WRAP_C("write");
     LockFactory *lock_factory = S_obtain_lock_factory(self);
     return LockFact_Make_Lock(lock_factory, write_lock_name,
-                              ivars->write_lock_timeout,
-                              ivars->write_lock_interval);
+                              (int32_t)ivars->write_lock_timeout,
+                              (int32_t)ivars->write_lock_interval);
 }
 
 Lock*
@@ -247,8 +247,8 @@ IxManager_Make_Deletion_Lock_IMP(IndexManager *self) {
     String *lock_name = SSTR_WRAP_C("deletion");
     LockFactory *lock_factory = S_obtain_lock_factory(self);
     return LockFact_Make_Lock(lock_factory, lock_name,
-                              ivars->deletion_lock_timeout,
-                              ivars->deletion_lock_interval);
+                              (int32_t)ivars->deletion_lock_timeout,
+                              (int32_t)ivars->deletion_lock_interval);
 }
 
 Lock*
@@ -257,8 +257,8 @@ IxManager_Make_Merge_Lock_IMP(IndexManager *self) {
     String *merge_lock_name = SSTR_WRAP_C("merge");
     LockFactory *lock_factory = S_obtain_lock_factory(self);
     return LockFact_Make_Lock(lock_factory, merge_lock_name,
-                              ivars->merge_lock_timeout,
-                              ivars->merge_lock_interval);
+                              (int32_t)ivars->merge_lock_timeout,
+                              (int32_t)ivars->merge_lock_interval);
 }
 
 void
@@ -372,33 +372,51 @@ IxManager_Get_Deletion_Lock_Interval_IMP(IndexManager 
*self) {
 
 void
 IxManager_Set_Write_Lock_Timeout_IMP(IndexManager *self, uint32_t timeout) {
+    if (timeout > INT32_MAX) {
+        THROW(ERR, "Timeout can't be greater than INT32_MAX: %u32", timeout);
+    }
     IxManager_IVARS(self)->write_lock_timeout = timeout;
 }
 
 void
 IxManager_Set_Write_Lock_Interval_IMP(IndexManager *self, uint32_t interval) {
+    if (interval > INT32_MAX) {
+        THROW(ERR, "Interval can't be greater than INT32_MAX: %u32", interval);
+    }
     IxManager_IVARS(self)->write_lock_interval = interval;
 }
 
 void
 IxManager_Set_Merge_Lock_Timeout_IMP(IndexManager *self, uint32_t timeout) {
+    if (timeout > INT32_MAX) {
+        THROW(ERR, "Timeout can't be greater than INT32_MAX: %u32", timeout);
+    }
     IxManager_IVARS(self)->merge_lock_timeout = timeout;
 }
 
 void
 IxManager_Set_Merge_Lock_Interval_IMP(IndexManager *self, uint32_t interval) {
+    if (interval > INT32_MAX) {
+        THROW(ERR, "Interval can't be greater than INT32_MAX: %u32", interval);
+    }
     IxManager_IVARS(self)->merge_lock_interval = interval;
 }
 
 void
 IxManager_Set_Deletion_Lock_Timeout_IMP(IndexManager *self,
                                         uint32_t timeout) {
+    if (timeout > INT32_MAX) {
+        THROW(ERR, "Timeout can't be greater than INT32_MAX: %u32", timeout);
+    }
     IxManager_IVARS(self)->deletion_lock_timeout = timeout;
 }
 
 void
 IxManager_Set_Deletion_Lock_Interval_IMP(IndexManager *self,
                                          uint32_t interval) {
+    if (interval > INT32_MAX) {
+        THROW(ERR, "Interval can't be greater than INT32_MAX: %u32", interval);
+    }
     IxManager_IVARS(self)->deletion_lock_interval = interval;
 }
 

Reply via email to