proc_mutex.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "fspr.h"
  17. #include "fspr_private.h"
  18. #include "fspr_portable.h"
  19. #include "fspr_arch_proc_mutex.h"
  20. #include "fspr_arch_thread_mutex.h"
  21. APR_DECLARE(fspr_status_t) fspr_proc_mutex_create(fspr_proc_mutex_t **mutex,
  22. const char *fname,
  23. fspr_lockmech_e mech,
  24. fspr_pool_t *pool)
  25. {
  26. fspr_status_t ret;
  27. fspr_proc_mutex_t *new_mutex = NULL;
  28. new_mutex = (fspr_proc_mutex_t *)fspr_pcalloc(pool, sizeof(fspr_proc_mutex_t));
  29. if(new_mutex ==NULL) {
  30. return APR_ENOMEM;
  31. }
  32. new_mutex->pool = pool;
  33. ret = fspr_thread_mutex_create(&(new_mutex->mutex), APR_THREAD_MUTEX_DEFAULT, pool);
  34. if (ret == APR_SUCCESS)
  35. *mutex = new_mutex;
  36. return ret;
  37. }
  38. APR_DECLARE(fspr_status_t) fspr_proc_mutex_child_init(fspr_proc_mutex_t **mutex,
  39. const char *fname,
  40. fspr_pool_t *pool)
  41. {
  42. return APR_SUCCESS;
  43. }
  44. APR_DECLARE(fspr_status_t) fspr_proc_mutex_lock(fspr_proc_mutex_t *mutex)
  45. {
  46. if (mutex)
  47. return fspr_thread_mutex_lock(mutex->mutex);
  48. return APR_ENOLOCK;
  49. }
  50. APR_DECLARE(fspr_status_t) fspr_proc_mutex_trylock(fspr_proc_mutex_t *mutex)
  51. {
  52. if (mutex)
  53. return fspr_thread_mutex_trylock(mutex->mutex);
  54. return APR_ENOLOCK;
  55. }
  56. APR_DECLARE(fspr_status_t) fspr_proc_mutex_unlock(fspr_proc_mutex_t *mutex)
  57. {
  58. if (mutex)
  59. return fspr_thread_mutex_unlock(mutex->mutex);
  60. return APR_ENOLOCK;
  61. }
  62. APR_DECLARE(fspr_status_t) fspr_proc_mutex_cleanup(void *mutex)
  63. {
  64. return fspr_proc_mutex_destroy(mutex);
  65. }
  66. APR_DECLARE(fspr_status_t) fspr_proc_mutex_destroy(fspr_proc_mutex_t *mutex)
  67. {
  68. if (mutex)
  69. return fspr_thread_mutex_destroy(mutex->mutex);
  70. return APR_ENOLOCK;
  71. }
  72. APR_DECLARE(const char *) fspr_proc_mutex_lockfile(fspr_proc_mutex_t *mutex)
  73. {
  74. return NULL;
  75. }
  76. APR_DECLARE(const char *) fspr_proc_mutex_name(fspr_proc_mutex_t *mutex)
  77. {
  78. return "netwarethread";
  79. }
  80. APR_DECLARE(const char *) fspr_proc_mutex_defname(void)
  81. {
  82. return "netwarethread";
  83. }
  84. APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
  85. /* Implement OS-specific accessors defined in fspr_portable.h */
  86. fspr_status_t fspr_os_proc_mutex_get(fspr_os_proc_mutex_t *ospmutex,
  87. fspr_proc_mutex_t *pmutex)
  88. {
  89. if (pmutex)
  90. ospmutex = pmutex->mutex->mutex;
  91. return APR_ENOLOCK;
  92. }
  93. fspr_status_t fspr_os_proc_mutex_put(fspr_proc_mutex_t **pmutex,
  94. fspr_os_proc_mutex_t *ospmutex,
  95. fspr_pool_t *pool)
  96. {
  97. return APR_ENOTIMPL;
  98. }