Skip to content

Conversation

@matthiasgoergens
Copy link
Contributor

Brian Donegan sent in a patch.

I recommend reviewing with git diff --ignore-all-space

Signed-off-by: Matthias Goergens <matthias.goergens@gmail.com>
parse_result_code of ocaml/xapi/workload_balancing.ml is called if
there is a result from a call to the WLB server.  In Windows, WLB's
Windows-Communication-Foundation web service returns no result when a
call is successful (obeying the WCF data contract).  When the same
code is run under Mono, the web service returns ResultCode = 0, which
XAPI is currently treating as an actual error.  The change is meant to
check the actual code rather than just assuming that since there is
one, that there was an error.

Brian Donegan sent in the original patch, that Matthias adapted.

Signed-off-by: Matthias Goergens <matthias.goergens@gmail.com>
@djs55
Copy link
Contributor

djs55 commented Feb 17, 2011

Hmm

*** omake: done (0.26 sec, 0/0 scans, 2/4 rules, 0/421 digests)
omake phase3
*** omake: reading OMakefiles
which: no pstopdf in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/djs/bin)
*** omake: finished reading OMakefiles (0.17 sec)

  • build ocaml/xapi workload_balancing.cmx
  • ocamlfind ocamlopt -package xc,xs,cpuid,xml-light2,cdrom,pciutil,sexpr,log,stunnel,http-svr,rss,xen-utils,netdev,tapctl,vhd,xs,rpc-light -g -dtypes -thread -warn-error F -ccopt -fPIC -I ../idl -I ../idl/ocaml_backend -I ../autogen -I ../database/ -I ../xenops -I ../xva -I ../util -I ../auth -I ../license -I ../client_records -I ../rfb -I ../gpg -c workload_balancing.ml
    File "workload_balancing.ml", line 240, characters 13-14:
    Error: This expression has type int but an expression was expected of type
    string
    *** omake: 1723/2843 targets are up to date
    *** omake: failed (1.54 sec, 0/383 scans, 1/725 rules, 0/2479 digests)
    *** omake: targets were not rebuilt because of errors:
    ocaml/xapi/workload_balancing.cmi
    depends on: ocaml/xapi/workload_balancing.ml
    ocaml/xapi/workload_balancing.cmx
    depends on: ocaml/xapi/workload_balancing.ml
    ocaml/xapi/workload_balancing.o
    depends on: ocaml/xapi/workload_balancing.ml
    make: *** [all] Error 2
    [djs@jwinclient xen-api]$

@matthiasgoergens
Copy link
Contributor Author

Thanks. I'll forward that error to Brian. (And I'll try to do building on my own first, before sending the next pull-request. :o)

@briandon
Copy link

Thanks guys. After getting the change sorted (I think), I am getting the following errors for vmops.ml:

File "vmops.ml", line 719, characters 6-14:
Warning 26: unused variable platform.================================== ] 02401 / 02843
File "vmops.ml", line 95, characters 39-333:
Error: This expression has type carrier:bool -> Device_common.device
but an expression was expected of type Device_common.device
*** omake: 2401/2843 targets are up to date
*** omake: failed (1.97 sec, 0/472 scans, 1/1223 rules, 0/3058 digests)
*** omake: targets were not rebuilt because of errors:
ocaml/xapi/vmops.cmi
depends on: ocaml/xapi/vmops.ml
ocaml/xapi/vmops.cmx
depends on: ocaml/xapi/vmops.ml
ocaml/xapi/vmops.o
depends on: ocaml/xapi/vmops.ml

Thoughts? I will try a clean build this morning.

@matthiasgoergens
Copy link
Contributor Author

Here's the error message in a readable formatting (just indent by at least 4 spaces or a tab to make markdown show code):

File "vmops.ml", line 719, characters 6-14:
Warning 26: unused variable platform.==================================              ] 02401 / 02843
File "vmops.ml", line 95, characters 39-333:
Error: This expression has type carrier:bool -> Device_common.device
       but an expression was expected of type Device_common.device
*** omake: 2401/2843 targets are up to date
*** omake: failed (1.97 sec, 0/472 scans, 1/1223 rules, 0/3058 digests)
*** omake: targets were not rebuilt because of errors:
   ocaml/xapi/vmops.cmi
      depends on: ocaml/xapi/vmops.ml
   ocaml/xapi/vmops.cmx
      depends on: ocaml/xapi/vmops.ml
   ocaml/xapi/vmops.o
      depends on: ocaml/xapi/vmops.ml

@mcclurmc
Copy link
Contributor

Brian, can you push your new changes to github so we can see them? You're showing an error in vmops.ml, but neither of these patches affect that file...

@xen-git
Copy link
Contributor

xen-git commented Mar 8, 2011

Failed to merge and build matthiasgoergens/xen-api@fd59f67b9ad972c96d1ec0d7687d6232d0b6b548 with 3c8d093.

Failed when executing:
make api-build
Error log:
+ ocamlfind ocamlopt -package xc,xs,cpuid,xml-light2,cdrom,pciutil,sexpr,log,stunnel,http-svr,rss,xen-utils,netdev,tapctl,vhd,xs,rpc-light -g -dtypes -thread -warn-error F -ccopt -fPIC -I ../idl -I ../idl/ocaml_backend -I ../autogen -I ../database/ -I ../xenops -I ../xva -I ../util -I ../auth -I ../license -I ../client_records -I ../rfb -I ../gpg -c workload_balancing.ml
File "workload_balancing.ml", line 240, characters 13-14:
Error: This expression has type int but an expression was expected of type
string
*** omake: 2027/2839 targets are up to date
*** omake: failed (1 min 12.30 sec, 370/425 scans, 364/946 rules, 1181/3459 digests)
*** omake: targets were not rebuilt because of errors:
ocaml/xapi/workload_balancing.cmi
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.cmx
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.o
depends on: ocaml/xapi/workload_balancing.ml
make[4]: *** [all] Error 2
error: Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.33351 (%build)

RPM build errors:
    Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.33351 (%build)
make[3]: *** [/output/api/cli-regress.tar.gz] Error 1

@xen-git
Copy link
Contributor

xen-git commented Mar 8, 2011

Failed to merge and build matthiasgoergens/xen-api@fd59f67b9ad972c96d1ec0d7687d6232d0b6b548 with 4e6bc27.

Failed when executing:
make api-build
Error log:
+ ocamlfind ocamlopt -package xc,xs,cpuid,xml-light2,cdrom,pciutil,sexpr,log,stunnel,http-svr,rss,xen-utils,netdev,tapctl,vhd,xs,rpc-light -g -dtypes -thread -warn-error F -ccopt -fPIC -I ../idl -I ../idl/ocaml_backend -I ../autogen -I ../database/ -I ../xenops -I ../xva -I ../util -I ../auth -I ../license -I ../client_records -I ../rfb -I ../gpg -c workload_balancing.ml
File "workload_balancing.ml", line 240, characters 13-14:
Error: This expression has type int but an expression was expected of type
string
*** omake: 2027/2839 targets are up to date
*** omake: failed (1 min 12.58 sec, 370/425 scans, 364/946 rules, 1181/3459 digests)
*** omake: targets were not rebuilt because of errors:
ocaml/xapi/workload_balancing.cmi
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.cmx
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.o
depends on: ocaml/xapi/workload_balancing.ml
make[4]: *** [all] Error 2
error: Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.3707 (%build)

RPM build errors:
    Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.3707 (%build)
make[3]: *** [/output/api/cli-regress.tar.gz] Error 1

@xen-git
Copy link
Contributor

xen-git commented Mar 11, 2011

Failed to merge and build matthiasgoergens/xen-api@fd59f67b9ad972c96d1ec0d7687d6232d0b6b548 with 812c68b.

Failed when executing:
make api-build
Error log:
+ ocamlfind ocamlopt -package xc,xs,cpuid,xml-light2,cdrom,pciutil,sexpr,log,stunnel,http-svr,rss,xen-utils,netdev,tapctl,vhd,xs,rpc-light -g -dtypes -thread -warn-error F -ccopt -fPIC -I ../idl -I ../idl/ocaml_backend -I ../autogen -I ../database/ -I ../xenops -I ../xva -I ../util -I ../auth -I ../license -I ../client_records -I ../rfb -I ../gpg -c workload_balancing.ml
File "workload_balancing.ml", line 240, characters 13-14:
Error: This expression has type int but an expression was expected of type
string
*** omake: 2027/2839 targets are up to date
*** omake: failed (1 min 12.46 sec, 370/425 scans, 364/946 rules, 1181/3458 digests)
*** omake: targets were not rebuilt because of errors:
ocaml/xapi/workload_balancing.cmi
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.cmx
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.o
depends on: ocaml/xapi/workload_balancing.ml
make[4]: *** [all] Error 2
error: Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.71472 (%build)

RPM build errors:
    Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.71472 (%build)
make[3]: *** [/output/api/cli-regress.tar.gz] Error 1

@xen-git
Copy link
Contributor

xen-git commented Mar 11, 2011

Failed to merge and build matthiasgoergens/xen-api@fd59f67b9ad972c96d1ec0d7687d6232d0b6b548 with 8aca8de.

Failed when executing:
make api-build
Error log:
+ ocamlfind ocamlopt -package xc,xs,cpuid,xml-light2,cdrom,pciutil,sexpr,log,stunnel,http-svr,rss,xen-utils,netdev,tapctl,vhd,xs,rpc-light -g -dtypes -thread -warn-error F -ccopt -fPIC -I ../idl -I ../idl/ocaml_backend -I ../autogen -I ../database/ -I ../xenops -I ../xva -I ../util -I ../auth -I ../license -I ../client_records -I ../rfb -I ../gpg -c workload_balancing.ml
File "workload_balancing.ml", line 240, characters 13-14:
Error: This expression has type int but an expression was expected of type
string
*** omake: 2027/2839 targets are up to date
*** omake: failed (1 min 11.74 sec, 370/425 scans, 364/946 rules, 1181/3459 digests)
*** omake: targets were not rebuilt because of errors:
ocaml/xapi/workload_balancing.cmi
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.cmx
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.o
depends on: ocaml/xapi/workload_balancing.ml
make[4]: *** [all] Error 2
error: Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.50179 (%build)

RPM build errors:
    Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.50179 (%build)
make[3]: *** [/output/api/cli-regress.tar.gz] Error 1

@xen-git
Copy link
Contributor

xen-git commented Mar 15, 2011

Failed to merge and build matthiasgoergens/xen-api@fd59f67b9ad972c96d1ec0d7687d6232d0b6b548 with 2cbf7b7.

Failed when executing:
make api-build
Error log:
+ ocamlfind ocamlopt -package xc,xs,cpuid,xml-light2,cdrom,pciutil,sexpr,log,stunnel,http-svr,rss,xen-utils,netdev,tapctl,vhd,xs,rpc-light -g -dtypes -thread -warn-error F -ccopt -fPIC -I ../idl -I ../idl/ocaml_backend -I ../autogen -I ../database/ -I ../xenops -I ../xva -I ../util -I ../auth -I ../license -I ../client_records -I ../rfb -I ../gpg -c workload_balancing.ml
File "workload_balancing.ml", line 240, characters 13-14:
Error: This expression has type int but an expression was expected of type
string
*** omake: 2034/2846 targets are up to date
*** omake: failed (1 min 14.11 sec, 372/427 scans, 366/949 rules, 1186/3471 digests)
*** omake: targets were not rebuilt because of errors:
ocaml/xapi/workload_balancing.cmi
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.cmx
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.o
depends on: ocaml/xapi/workload_balancing.ml
make[4]: *** [all] Error 2
error: Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.51542 (%build)

RPM build errors:
    Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.51542 (%build)
make[3]: *** [/output/api/cli-regress.tar.gz] Error 1

@xen-git
Copy link
Contributor

xen-git commented Mar 16, 2011

Failed to merge and build matthiasgoergens/xen-api@fd59f67b9ad972c96d1ec0d7687d6232d0b6b548 with d45bd4c.

Failed when executing:
make api-build
Error log:
+ ocamlfind ocamlopt -package xc,xs,cpuid,xml-light2,cdrom,pciutil,sexpr,log,stunnel,http-svr,rss,xen-utils,netdev,tapctl,vhd,xs,rpc-light -g -dtypes -thread -warn-error F -ccopt -fPIC -I ../idl -I ../idl/ocaml_backend -I ../autogen -I ../database/ -I ../xenops -I ../xva -I ../util -I ../auth -I ../license -I ../client_records -I ../rfb -I ../gpg -c workload_balancing.ml
File "workload_balancing.ml", line 240, characters 13-14:
Error: This expression has type int but an expression was expected of type
string
*** omake: 2034/2846 targets are up to date
*** omake: failed (1 min 14.42 sec, 372/427 scans, 366/949 rules, 1186/3470 digests)
*** omake: targets were not rebuilt because of errors:
ocaml/xapi/workload_balancing.cmi
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.cmx
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.o
depends on: ocaml/xapi/workload_balancing.ml
make[4]: *** [all] Error 2
error: Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.65326 (%build)

RPM build errors:
    Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.65326 (%build)
make[3]: *** [/output/api/cli-regress.tar.gz] Error 1

@matthiasgoergens
Copy link
Contributor Author

Dave, you've been replaced by a bot. :o)

@xen-git
Copy link
Contributor

xen-git commented Mar 16, 2011

Failed to merge and build matthiasgoergens/xen-api@fd59f67b9ad972c96d1ec0d7687d6232d0b6b548 with f47d0dd.

Failed when executing:
make api-build
Error log:
+ ocamlfind ocamlopt -package xc,xs,cpuid,xml-light2,cdrom,pciutil,sexpr,log,stunnel,http-svr,rss,xen-utils,netdev,tapctl,vhd,xs,rpc-light -g -dtypes -thread -warn-error F -ccopt -fPIC -I ../idl -I ../idl/ocaml_backend -I ../autogen -I ../database/ -I ../xenops -I ../xva -I ../util -I ../auth -I ../license -I ../client_records -I ../rfb -I ../gpg -c workload_balancing.ml
File "workload_balancing.ml", line 240, characters 13-14:
Error: This expression has type int but an expression was expected of type
string
*** omake: 2076/2888 targets are up to date
*** omake: failed (1 min 17.47 sec, 384/439 scans, 378/967 rules, 1216/3542 digests)
*** omake: targets were not rebuilt because of errors:
ocaml/xapi/workload_balancing.cmi
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.cmx
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.o
depends on: ocaml/xapi/workload_balancing.ml
make[4]: *** [all] Error 2
error: Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.68582 (%build)

RPM build errors:
    Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.68582 (%build)
make[3]: *** [/output/api/cli-regress.tar.gz] Error 1

@xen-git
Copy link
Contributor

xen-git commented Mar 17, 2011

Failed to merge and build matthiasgoergens/xen-api@fd59f67b9ad972c96d1ec0d7687d6232d0b6b548 with 2f63e3a.

Failed when executing:
make api-build
Error log:
+ ocamlfind ocamlopt -package xc,xs,cpuid,xml-light2,cdrom,pciutil,sexpr,log,stunnel,http-svr,rss,xen-utils,netdev,tapctl,vhd,xs,rpc-light -g -dtypes -thread -warn-error F -ccopt -fPIC -I ../idl -I ../idl/ocaml_backend -I ../autogen -I ../database/ -I ../xenops -I ../xva -I ../util -I ../auth -I ../license -I ../client_records -I ../rfb -I ../gpg -c workload_balancing.ml
File "workload_balancing.ml", line 240, characters 13-14:
Error: This expression has type int but an expression was expected of type
string
*** omake: 2076/2888 targets are up to date
*** omake: failed (1 min 16.25 sec, 384/439 scans, 378/967 rules, 1216/3542 digests)
*** omake: targets were not rebuilt because of errors:
ocaml/xapi/workload_balancing.cmi
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.cmx
depends on: ocaml/xapi/workload_balancing.ml
ocaml/xapi/workload_balancing.o
depends on: ocaml/xapi/workload_balancing.ml
make[4]: *** [all] Error 2
error: Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.52920 (%build)

RPM build errors:
    Bad exit status from /obj/RPM_BUILD_DIRECTORY/tmp/rpm-tmp.52920 (%build)
make[3]: *** [/output/api/cli-regress.tar.gz] Error 1

@matthiasgoergens
Copy link
Contributor Author

Re-open, if there's a chance it will build.

sharady pushed a commit to sharady/xen-api that referenced this pull request May 11, 2015
sharady pushed a commit to sharady/xen-api that referenced this pull request May 29, 2015
[Caboodle/HFX-1385] CA-163866: VM hard_reboot must cancel clean_reboot on slaves
koushikcgit pushed a commit to koushikcgit/xen-api that referenced this pull request Aug 7, 2015
CA-116819: xenlight: don't attach storage during VM_restore
kc284 pushed a commit to kc284/xen-api that referenced this pull request Mar 11, 2021
XOP-541: Include assemblyCompany attribute to dll files.
robhoes pushed a commit to robhoes/xen-api that referenced this pull request Jul 6, 2021
robhoes pushed a commit that referenced this pull request Sep 14, 2021
robhoes pushed a commit that referenced this pull request Sep 14, 2021
robhoes pushed a commit that referenced this pull request Sep 14, 2021
robhoes pushed a commit that referenced this pull request Sep 14, 2021
psafont pushed a commit to psafont/xen-api that referenced this pull request Sep 20, 2021
CP-14346: Remove modules made obsolete by new CPU feature levelling v2
robhoes pushed a commit to robhoes/xen-api that referenced this pull request Sep 21, 2021
robhoes pushed a commit to robhoes/xen-api that referenced this pull request Sep 21, 2021
lindig added a commit to lindig/xen-api that referenced this pull request Nov 9, 2021
xenops-cli: port to ppx_deriving_rpc and jbuilder
lindig added a commit to lindig/xen-api that referenced this pull request Dec 17, 2021
Merge ppx_trunk into master for moving to OCaml 4.02.3 and PPX
robhoes pushed a commit to robhoes/xen-api that referenced this pull request Jan 10, 2022
CP-330919: Revert changes for CP-32138
psafont pushed a commit to psafont/xen-api that referenced this pull request Jan 10, 2022
Compatibility update for xen-api-client v0.10.0
robhoes pushed a commit to robhoes/xen-api that referenced this pull request Jan 10, 2022
…ture/CBT_add_vdi_info_cbt_enabled

CP-22446: Add new cbt_enabled vdi_info param to vdi_create command
robhoes pushed a commit to robhoes/xen-api that referenced this pull request Apr 7, 2022
Merge ppx_trunk into master for moving to OCaml 4.02.3 and PPX
edwintorok added a commit to edwintorok/xen-api that referenced this pull request Oct 10, 2023
Using an off-cpu flamegraph I identified that concurrent PAM calls are slow due to a call to `sleep(1)`.
`pam_authenticate` calls `crypt_r` which calls `NSSLOW_Init` which on first use will try to initialize the just `dlopen`-ed library.
If it encounters a race condition it does a `sleep(1)`. This race condition can be quite reliably reproduced when performing a lot of PAM authentications from multiple threads in parallel.

GDB can also be used to confirm this by putting a breakpoint on `sleep`:
```
 #0  __sleep (seconds=seconds@entry=1) at ../sysdeps/unix/sysv/linux/sleep.c:42
 #1  0x00007ffff1548e22 in freebl_RunLoaderOnce () at lowhash_vector.c:122
 #2  0x00007ffff1548f31 in freebl_InitVector () at lowhash_vector.c:131
 #3  NSSLOW_Init () at lowhash_vector.c:148
 #4  0x00007ffff1b8f09a in __sha512_crypt_r (key=key@entry=0x7fffd8005a60 "pamtest-edvint", salt=0x7ffff31e17b8 "dIJbsXKc0",
 xapi-project#5  0x00007ffff1b8d070 in __crypt_r (key=key@entry=0x7fffd8005a60 "pamtest-edvint", salt=<optimized out>,
 xapi-project#6  0x00007ffff1dc9abc in verify_pwd_hash (p=p@entry=0x7fffd8005a60 "pamtest-edvint", hash=<optimized out>, nullok=nullok@entry=0) at passverify.c:111
 xapi-project#7  0x00007ffff1dc9139 in _unix_verify_password (pamh=pamh@entry=0x7fffd8002910, name=0x7fffd8002ab0 "pamtest-edvint", p=0x7fffd8005a60 "pamtest-edvint", ctrl=ctrl@entry=8389156) at support.c:777
 xapi-project#8  0x00007ffff1dc6556 in pam_sm_authenticate (pamh=0x7fffd8002910, flags=<optimized out>, argc=<optimized out>, argv=<optimized out>) at pam_unix_auth.c:178
 xapi-project#9  0x00007ffff7bcef1a in _pam_dispatch_aux (use_cached_chain=<optimized out>, resumed=<optimized out>, h=<optimized out>, flags=1, pamh=0x7fffd8002910) at pam_dispatch.c:110
 xapi-project#10 _pam_dispatch (pamh=pamh@entry=0x7fffd8002910, flags=1, choice=choice@entry=1) at pam_dispatch.c:426
 xapi-project#11 0x00007ffff7bce7e0 in pam_authenticate (pamh=0x7fffd8002910, flags=flags@entry=1) at pam_auth.c:34
 xapi-project#12 0x00000000005ae567 in XA_mh_authorize (username=username@entry=0x7fffd80028d0 "pamtest-edvint", password=password@entry=0x7fffd80028f0 "pamtest-edvint", error=error@entry=0x7ffff31e1be8) at xa_auth.c:83
 xapi-project#13 0x00000000005adf20 in stub_XA_mh_authorize (username=<optimized out>, password=<optimized out>) at xa_auth_stubs.c:42
 xapi-project#14 0x00000000004a0a6a in camlDune__exe__Bench_pam__pam_authenticate$27_320 () at ocaml/tests/bench/pam/bench_pam.ml:63
 xapi-project#15 0x00000000004a1113 in camlEzbechamel_concurrent__worker_loop_359 () at ocaml/tests/bench/lib/concurrent/ezbechamel_concurrent.ml:36
 xapi-project#16 0x00000000005935b9 in camlStdlib__Fun__protect_317 ()
 xapi-project#17 0x00000000004a1955 in camlThread__fun_850 ()
 xapi-project#18 0x00000000005d6401 in caml_start_program ()
 xapi-project#19 0x00000000005cd0fd in caml_callback_exn ()
 xapi-project#20 0x00000000005af810 in caml_thread_start ()
 xapi-project#21 0x00007ffff79b7e25 in start_thread (arg=0x7ffff31e2700) at pthread_create.c:308
 xapi-project#22 0x00007ffff71dbbad in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113
```

`pam_start` and `pam_end` doesn't help here, because on `pam_end` the library is `dlclose`-ed, so on next `pam_authenticate` it will have to go through the initialization code again.
(This initialization code would've belonged into `pam_start`, not `pam_authenticate`, but there are several layers here including a call to `crypt_r`).

To avoid this link with `libcrypt` and call `crypt_r` once ourselves (and ensure it loads `libfreeblpriv3` by using the sha512 prefix).
That way the library will stay loaded (we'll hold a reference count on it), and the `dlclose` done by PAM won't unload it.

Confirmed that there are no `sleep` calls now, and the results are also visible when running the benchmark targeted to the with and without fix code:
```
╭─────────────────────────────────────────────────┬───────────────────────────┬───────────────────────────┬───────────────────────────╮
│name                                             │  major-allocated          │  minor-allocated          │  monotonic-clock          │
├─────────────────────────────────────────────────┼───────────────────────────┼───────────────────────────┼───────────────────────────┤
│  concurrent authenticate (sleep fix, actual):8  │             0.0000 mjw/run│            50.0000 mnw/run│       27043467.0000 ns/run│
╰─────────────────────────────────────────────────┴───────────────────────────┴───────────────────────────┴───────────────────────────╯

╭────────────────────────────────────────┬───────────────────────────┬───────────────────────────┬───────────────────────────╮
│name                                    │  major-allocated          │  minor-allocated          │  monotonic-clock          │
├────────────────────────────────────────┼───────────────────────────┼───────────────────────────┼───────────────────────────┤
│  concurrent authenticate (no reuse):8  │             0.0000 mjw/run│            50.0000 mnw/run│     1029831372.0000 ns/run│
╰────────────────────────────────────────┴───────────────────────────┴───────────────────────────┴───────────────────────────╯
```

Without this fix using 2 threads to perform PAM authentication would result in a 38x slowdown compared to using no threads at all (which is what XAPI currently does).

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
edwintorok pushed a commit to edwintorok/xen-api that referenced this pull request Jan 22, 2024
edwintorok pushed a commit to edwintorok/xen-api that referenced this pull request Jan 22, 2024
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants