You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.5 KiB

  1. --- a/CMakeLists.txt
  2. +++ b/CMakeLists.txt
  3. @@ -176,6 +176,7 @@ target_link_libraries(netconf2 ${CMAKE_THREAD_LIBS_INIT})
  4. set(CMAKE_REQUIRED_LIBRARIES pthread)
  5. check_include_file(stdatomic.h HAVE_STDATOMIC)
  6. check_function_exists(pthread_mutex_timedlock HAVE_PTHREAD_MUTEX_TIMEDLOCK)
  7. +check_function_exists(pthread_rwlockattr_setkind_np HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP)
  8. # dependencies - openssl
  9. if(ENABLE_TLS OR ENABLE_DNSSEC OR ENABLE_SSH)
  10. --- a/src/config.h.in
  11. +++ b/src/config.h.in
  12. @@ -73,4 +73,7 @@
  13. */
  14. #define NC_PS_QUEUE_SIZE @MAX_PSPOLL_THREAD_COUNT@
  15. +/* Portability feature-check macros. */
  16. +#cmakedefine HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP
  17. +
  18. #endif /* NC_CONFIG_H_ */
  19. --- a/src/session_server.c
  20. +++ b/src/session_server.c
  21. @@ -560,6 +560,7 @@ nc_server_init(struct ly_ctx *ctx)
  22. errno=0;
  23. if (pthread_rwlockattr_init(&attr) == 0) {
  24. +#if defined(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP)
  25. if (pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP) == 0) {
  26. if (pthread_rwlock_init(&server_opts.endpt_lock, &attr) != 0) {
  27. ERR("%s: failed to init rwlock(%s).", __FUNCTION__, strerror(errno));
  28. @@ -570,6 +571,7 @@ nc_server_init(struct ly_ctx *ctx)
  29. } else {
  30. ERR("%s: failed set attribute (%s).", __FUNCTION__, strerror(errno));
  31. }
  32. +#endif
  33. pthread_rwlockattr_destroy(&attr);
  34. } else {
  35. ERR("%s: failed init attribute (%s).", __FUNCTION__, strerror(errno));