Changeset 3535439f in rtems


Ignore:
Timestamp:
Jan 3, 2018, 3:17:21 PM (19 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
2aa5b98
Parents:
71a8446
git-author:
Sebastian Huber <sebastian.huber@…> (01/03/18 15:17:21)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/07/18 07:58:31)
Message:

tftpfs: Use self-contained mutex

Update #2843.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libnetworking/lib/tftpDriver.c

    r71a8446 r3535439f  
    3131#include <rtems/rtems_bsdnet.h>
    3232#include <rtems/tftp.h>
     33#include <rtems/thread.h>
    3334#include <sys/types.h>
    3435#include <sys/socket.h>
     
    152153typedef struct tftpfs_info_s {
    153154  uint32_t flags;
    154   rtems_id tftp_mutex;
     155  rtems_mutex tftp_mutex;
    155156  int nStreams;
    156157  struct tftpStream ** volatile tftpStreams;
     
    181182)
    182183{
    183   rtems_status_code  sc;
    184184  const char *device = mt_entry->dev;
    185185  size_t devicelen = strlen (device);
     
    214214   */
    215215
    216   sc = rtems_semaphore_create (
    217     rtems_build_name('T', 'F', 'T', 'P'),
    218     1,
    219     RTEMS_BINARY_SEMAPHORE |
    220     RTEMS_PRIORITY |
    221     RTEMS_INHERIT_PRIORITY,
    222     0,
    223     &fs->tftp_mutex
    224   );
    225 
    226   if (sc != RTEMS_SUCCESSFUL)
    227       goto error;
     216  rtems_mutex_init (&fs->tftp_mutex, "TFTPFS");
    228217
    229218  if (data) {
     
    257246    if (fs->tftpStreams[s] && (fs->tftpStreams[s]->socket >= 0))
    258247        close (fs->tftpStreams[s]->socket);
    259     rtems_semaphore_obtain (fs->tftp_mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     248    rtems_mutex_lock (&fs->tftp_mutex);
    260249    free (fs->tftpStreams[s]);
    261250    fs->tftpStreams[s] = NULL;
    262     rtems_semaphore_release (fs->tftp_mutex);
     251    rtems_mutex_unlock (&fs->tftp_mutex);
    263252}
    264253
     
    270259  for (s = 0; s < fs->nStreams; s++)
    271260      releaseStream (fs, s);
    272   rtems_semaphore_delete (fs->tftp_mutex);
     261  rtems_mutex_destroy (&fs->tftp_mutex);
    273262  free (fs);
    274263  free (mt_entry->mt_fs_root->location.node_access);
     
    537526    char                 *remoteFilename;
    538527    rtems_interval       now;
    539     rtems_status_code    sc;
    540528    char                 *hostname;
    541529
     
    584572     * Find a free stream
    585573     */
    586     sc = rtems_semaphore_obtain (fs->tftp_mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
    587     if (sc != RTEMS_SUCCESSFUL)
    588         return EBUSY;
     574    rtems_mutex_lock (&fs->tftp_mutex);
    589575    for (s = 0 ; s < fs->nStreams ; s++) {
    590576        if (fs->tftpStreams[s] == NULL)
     
    600586        np = realloc (fs->tftpStreams, ++fs->nStreams * sizeof *fs->tftpStreams);
    601587        if (np == NULL) {
    602             rtems_semaphore_release (fs->tftp_mutex);
     588            rtems_mutex_unlock (&fs->tftp_mutex);
    603589            return ENOMEM;
    604590        }
     
    606592    }
    607593    tp = fs->tftpStreams[s] = malloc (sizeof (struct tftpStream));
    608     rtems_semaphore_release (fs->tftp_mutex);
     594    rtems_mutex_unlock (&fs->tftp_mutex);
    609595    if (tp == NULL)
    610596        return ENOMEM;
Note: See TracChangeset for help on using the changeset viewer.