--- ntpd/refclock_jupiter.c.old	2003-10-07 23:10:39.000000000 +0200
+++ ntpd/refclock_jupiter.c	2005-09-21 18:46:14.900000000 +0200
@@ -188,7 +188,7 @@
 	struct refclockproc *pp;
 	struct instance *instance;
 	int fd = -1;
-	char gpsdev[20];
+	char gpsdev[20], id[20], path[20];
 
 	/*
 	 * Open serial port
@@ -233,8 +233,20 @@
 	 * Start the PPSAPI interface if it is there. Default to use
 	 * the assert edge and do not enable the kernel hardpps.
 	 */
+
+#ifdef PPS_HAVE_FINDSOURCE
+	/* Try to find the source (by using "index = -1" we ask just for a
+	 * generic source) */
+	fd = time_pps_findsource(-1, id, 40, path, 40);
+	if (fd < 0) {
+		msyslog(LOG_ERR, "refclock_jupiter: no available PPS source in the system");
+		return (1);
+	}
+	msyslog(LOG_INFO, "refclock_jupiter: found PPS source #%d \"%s\" on \"%s\"", fd, path, id);
+#endif   /* PPS_HAVE_FINDSOURCE */
+
+
 	if (time_pps_create(fd, &instance->pps_handle) < 0) {
-		instance->pps_handle = 0;
 		msyslog(LOG_ERR,
 			"refclock_jupiter: time_pps_create failed: %m");
 	}
@@ -269,10 +281,7 @@
 		return;
 
 #ifdef HAVE_PPSAPI
-	if (instance->pps_handle) {
-		time_pps_destroy(instance->pps_handle);
-		instance->pps_handle = 0;
-	}
+	time_pps_destroy(instance->pps_handle);
 #endif /* HAVE_PPSAPI */
 
 	io_closeclock(&pp->io);
@@ -406,8 +415,9 @@
 	/*
 	 * Convert the timespec nanoseconds field to ntp l_fp units.
 	 */ 
-	if (instance->pps_handle == 0)
+	/*	if (instance->pps_handle == 0)
 		return 1;
+	*/
 	timeout.tv_sec = 0;
 	timeout.tv_nsec = 0;
 	memcpy(&pps_info, &instance->pps_info, sizeof(pps_info_t));

