mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Initial port to Npth.
This commit is contained in:
parent
6cf8890dc1
commit
2959e9e4d1
43 changed files with 1012 additions and 1058 deletions
|
@ -26,8 +26,8 @@
|
|||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#ifdef USE_GNU_PTH
|
||||
# include <pth.h>
|
||||
#ifdef USE_NPTH
|
||||
# include <npth.h>
|
||||
#endif
|
||||
|
||||
#include "scdaemon.h"
|
||||
|
@ -147,7 +147,7 @@ static struct server_local_s *locked_session;
|
|||
|
||||
/* While doing a reset we need to make sure that the ticker does not
|
||||
call scd_update_reader_status_file while we are using it. */
|
||||
static pth_mutex_t status_file_update_lock;
|
||||
static npth_mutex_t status_file_update_lock;
|
||||
|
||||
|
||||
/*-- Local prototypes --*/
|
||||
|
@ -164,10 +164,12 @@ void
|
|||
initialize_module_command (void)
|
||||
{
|
||||
static int initialized;
|
||||
int err;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
if (pth_mutex_init (&status_file_update_lock))
|
||||
err = npth_mutex_init (&status_file_update_lock, NULL);
|
||||
if (!err)
|
||||
initialized = 1;
|
||||
}
|
||||
}
|
||||
|
@ -279,6 +281,7 @@ static void
|
|||
do_reset (ctrl_t ctrl, int send_reset)
|
||||
{
|
||||
int slot = ctrl->reader_slot;
|
||||
int err;
|
||||
|
||||
if (!(slot == -1 || (slot >= 0 && slot < DIM(slot_table))))
|
||||
BUG ();
|
||||
|
@ -326,16 +329,20 @@ do_reset (ctrl_t ctrl, int send_reset)
|
|||
try to update the file. Calling update_reader_status_file is
|
||||
required to get hold of the new status of the card in the slot
|
||||
table. */
|
||||
if (!pth_mutex_acquire (&status_file_update_lock, 0, NULL))
|
||||
err = npth_mutex_lock (&status_file_update_lock);
|
||||
if (err)
|
||||
{
|
||||
log_error ("failed to acquire status_fle_update lock\n");
|
||||
log_error ("failed to acquire status_fle_update lock: %s\n",
|
||||
strerror (err));
|
||||
ctrl->reader_slot = -1;
|
||||
return;
|
||||
}
|
||||
update_reader_status_file (0); /* Update slot status table. */
|
||||
update_card_removed (slot, 0); /* Clear card_removed flag. */
|
||||
if (!pth_mutex_release (&status_file_update_lock))
|
||||
log_error ("failed to release status_file_update lock\n");
|
||||
err = npth_mutex_unlock (&status_file_update_lock);
|
||||
if (err)
|
||||
log_error ("failed to release status_file_update lock: %s\n",
|
||||
strerror (err));
|
||||
|
||||
/* Do this last, so that the update_card_removed above does its job. */
|
||||
ctrl->reader_slot = -1;
|
||||
|
@ -1548,18 +1555,18 @@ cmd_lock (assuan_context_t ctx, char *line)
|
|||
else
|
||||
locked_session = ctrl->server_local;
|
||||
|
||||
#ifdef USE_GNU_PTH
|
||||
#ifdef USE_NPTH
|
||||
if (rc && has_option (line, "--wait"))
|
||||
{
|
||||
rc = 0;
|
||||
pth_sleep (1); /* Better implement an event mechanism. However,
|
||||
for card operations this should be
|
||||
sufficient. */
|
||||
npth_sleep (1); /* Better implement an event mechanism. However,
|
||||
for card operations this should be
|
||||
sufficient. */
|
||||
/* FIXME: Need to check that the connection is still alive.
|
||||
This can be done by issuing status messages. */
|
||||
goto retry;
|
||||
}
|
||||
#endif /*USE_GNU_PTH*/
|
||||
#endif /*USE_NPTH*/
|
||||
|
||||
if (rc)
|
||||
log_error ("cmd_lock failed: %s\n", gpg_strerror (rc));
|
||||
|
@ -2325,9 +2332,13 @@ update_reader_status_file (int set_card_removed_flag)
|
|||
void
|
||||
scd_update_reader_status_file (void)
|
||||
{
|
||||
if (!pth_mutex_acquire (&status_file_update_lock, 1, NULL))
|
||||
int err;
|
||||
err = npth_mutex_lock (&status_file_update_lock);
|
||||
if (err)
|
||||
return; /* locked - give up. */
|
||||
update_reader_status_file (1);
|
||||
if (!pth_mutex_release (&status_file_update_lock))
|
||||
log_error ("failed to release status_file_update lock\n");
|
||||
err = npth_mutex_unlock (&status_file_update_lock);
|
||||
if (err)
|
||||
log_error ("failed to release status_file_update lock: %s\n",
|
||||
strerror (err));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue