@@ -5063,9 +5063,9 @@ copy_subscription_attrs(
50635063 const char * name ; /* Current event name */
50645064
50655065
5066- cupsdLogMessage (CUPSD_LOG_DEBUG2 ,
5067- "copy_subscription_attrs(con=%p, sub=%p, ra=%p, exclude=%p)" ,
5068- ( void * ) con , ( void * ) sub , ( void * ) ra , ( void * ) exclude );
5066+ cupsdLogMessage (CUPSD_LOG_DEBUG2 , "copy_subscription_attrs(con=%p, sub=%p, ra=%p, exclude=%p)" , ( void * ) con , ( void * ) sub , ( void * ) ra , ( void * ) exclude );
5067+
5068+ _cupsRWLockRead ( & sub -> lock );
50695069
50705070 /*
50715071 * Copy the subscription attributes to the response using the
@@ -5156,6 +5156,8 @@ copy_subscription_attrs(
51565156 if (!ra || cupsArrayFind (ra , "notify-subscription-id" ))
51575157 ippAddInteger (con -> response , IPP_TAG_SUBSCRIPTION , IPP_TAG_INTEGER ,
51585158 "notify-subscription-id" , sub -> id );
5159+
5160+ _cupsRWUnlock (& sub -> lock );
51595161}
51605162
51615163
@@ -5433,7 +5435,6 @@ create_local_bg_thread(
54335435 goto finish_response ;
54345436 }
54355437
5436- // TODO: Grab printer icon file...
54375438 httpClose (http );
54385439
54395440 /*
@@ -7940,7 +7941,9 @@ get_subscriptions(cupsd_client_t *con, /* I - Client connection */
79407941 ipp_attribute_t * uri ) /* I - Printer/job URI */
79417942{
79427943 http_status_t status ; /* Policy status */
7943- int count ; /* Number of subscriptions */
7944+ int i , /* Looping var */
7945+ scount ; /* Total number of subscriptions */
7946+ int count ; /* Number of subscriptions returned */
79447947 int limit ; /* Limit */
79457948 cupsd_subscription_t * sub ; /* Subscription */
79467949 cups_array_t * ra ; /* Requested attributes array */
@@ -8064,9 +8067,12 @@ get_subscriptions(cupsd_client_t *con, /* I - Client connection */
80648067 else
80658068 username [0 ] = '\0' ;
80668069
8067- for (sub = (cupsd_subscription_t * )cupsArrayFirst (Subscriptions ), count = 0 ;
8068- sub ;
8069- sub = (cupsd_subscription_t * )cupsArrayNext (Subscriptions ))
8070+ _cupsRWLockRead (& SubscriptionsLock );
8071+
8072+ for (i = 0 , count = 0 , scount = cupsArrayCount (Subscriptions ); i < scount ; i ++ )
8073+ {
8074+ sub = (cupsd_subscription_t * )cupsArrayIndex (Subscriptions , i );
8075+
80708076 if ((!printer || sub -> dest == printer ) && (!job || sub -> job == job ) &&
80718077 (!username [0 ] || !_cups_strcasecmp (username , sub -> owner )))
80728078 {
@@ -8082,6 +8088,9 @@ get_subscriptions(cupsd_client_t *con, /* I - Client connection */
80828088 if (limit && count >= limit )
80838089 break ;
80848090 }
8091+ }
8092+
8093+ _cupsRWUnlock (& SubscriptionsLock );
80858094
80868095 cupsArrayDelete (ra );
80878096
@@ -9455,6 +9464,8 @@ renew_subscription(
94559464 * Renew the subscription...
94569465 */
94579466
9467+ _cupsRWLockWrite (& sub -> lock );
9468+
94589469 lease = ippFindAttribute (con -> request , "notify-lease-duration" ,
94599470 IPP_TAG_INTEGER );
94609471
@@ -9471,9 +9482,11 @@ renew_subscription(
94719482
94729483 sub -> expire = sub -> lease ? time (NULL ) + sub -> lease : 0 ;
94739484
9485+ _cupsRWUnlock (& sub -> lock );
9486+
94749487 cupsdMarkDirty (CUPSD_DIRTY_SUBSCRIPTIONS );
94759488
9476- con -> response -> request .status .status_code = IPP_OK ;
9489+ con -> response -> request .status .status_code = IPP_STATUS_OK ;
94779490
94789491 ippAddInteger (con -> response , IPP_TAG_SUBSCRIPTION , IPP_TAG_INTEGER ,
94799492 "notify-lease-duration" , sub -> lease );
0 commit comments