Skip to content

Commit cd13b3e

Browse files
authored
scheduler: Fix cupsd activated on-demand via socket
If only the expected cups.sock is set as listener in cupsd.conf, the array Listeners was NULL. To prevent copying the code, do the array allocation earlier and have only one check for Listeners, in service_checkin() which is run every time cupsd starts. Fixes #985
2 parents d0b16a2 + 145b946 commit cd13b3e

3 files changed

Lines changed: 16 additions & 40 deletions

File tree

CHANGES.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
CHANGES - OpenPrinting CUPS 2.4.9 - (2024-06-11)
1+
CHANGES - OpenPrinting CUPS 2.4.10 - (2024-06-18)
22
================================================
33

4-
Changes in CUPS v2.4.10 (TBD)
4+
Changes in CUPS v2.4.10 (2024-06-18)
55
-----------------------------
66

77
- Fixed error handling when reading a mixed `1setOf` attribute.
8+
- Fixed scheduler start if there is only domain socket to listen on (Issue #985)
89

910

1011
Changes in CUPS v2.4.9 (2024-06-11)

scheduler/conf.c

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,18 @@ cupsdReadConfiguration(void)
558558

559559
cupsdDeleteAllListeners();
560560

561+
/*
562+
* Allocate array Listeners
563+
*/
564+
565+
Listeners = cupsArrayNew(NULL, NULL);
566+
567+
if (!Listeners)
568+
{
569+
fprintf(stderr, "Unable to allocate memory for array Listeners.");
570+
return (0);
571+
}
572+
561573
old_remote_port = RemotePort;
562574
RemotePort = 0;
563575

@@ -1043,32 +1055,6 @@ cupsdReadConfiguration(void)
10431055
}
10441056
}
10451057

1046-
/*
1047-
* Check that we have at least one listen/port line; if not, report this
1048-
* as an error and exit!
1049-
*/
1050-
1051-
#ifdef HAVE_ONDEMAND
1052-
if (cupsArrayCount(Listeners) == 0 && !OnDemand)
1053-
#else
1054-
if (cupsArrayCount(Listeners) == 0)
1055-
#endif // HAVE_ONDEMAND
1056-
{
1057-
/*
1058-
* No listeners!
1059-
*/
1060-
1061-
cupsdLogMessage(CUPSD_LOG_EMERG,
1062-
"No valid Listen or Port lines were found in the "
1063-
"configuration file.");
1064-
1065-
/*
1066-
* Commit suicide...
1067-
*/
1068-
1069-
cupsdEndProcess(getpid(), 0);
1070-
}
1071-
10721058
/*
10731059
* Set the default locale using the language and charset...
10741060
*/
@@ -3155,17 +3141,6 @@ read_cupsd_conf(cups_file_t *fp) /* I - File to read from */
31553141
* Allocate another listener...
31563142
*/
31573143

3158-
if (!Listeners)
3159-
Listeners = cupsArrayNew(NULL, NULL);
3160-
3161-
if (!Listeners)
3162-
{
3163-
cupsdLogMessage(CUPSD_LOG_ERROR,
3164-
"Unable to allocate %s at line %d - %s.",
3165-
line, linenum, strerror(errno));
3166-
break;
3167-
}
3168-
31693144
if ((lis = calloc(1, sizeof(cupsd_listener_t))) == NULL)
31703145
{
31713146
cupsdLogMessage(CUPSD_LOG_ERROR,

scheduler/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,7 @@ service_checkin(void)
20432043
* No listeners!
20442044
*/
20452045

2046-
cupsdLogMessage(CUPSD_LOG_EMERG, "service_checkin: No listener sockets present.");
2046+
cupsdLogMessage(CUPSD_LOG_EMERG, "No listener sockets present.");
20472047

20482048
/*
20492049
* Commit suicide...

0 commit comments

Comments
 (0)