--- configure.ac.orig	2009-12-22 09:17:10.000000000 -0500
+++ configure.ac	2009-12-22 09:19:47.000000000 -0500
@@ -115,10 +115,9 @@
 AC_SUBST(GYPSY_LIBS)
 AC_SUBST(GYPSY_CFLAGS)
 
-AC_CHECK_LIB(gps, gps_open,[libgps=yes] )
+PKG_CHECK_MODULES(GPSD, [libgps >= 2.91],  have_gpsd="yes", have_gpsd="no")
 if test "x$libgps" = xyes; then
 	PROVIDER_SUBDIRS="$PROVIDER_SUBDIRS gpsd"
-    GPSD_LIBS="-lgps"
 else
 	NO_BUILD_PROVIDERS="$NO_BUILD_PROVIDERS gpsd"
 fi
--- providers/gpsd/geoclue-gpsd.c.orig	2009-12-22 09:20:55.000000000 -0500
+++ providers/gpsd/geoclue-gpsd.c	2009-12-22 09:30:04.000000000 -0500
@@ -43,7 +43,6 @@
 	char *host;
 	char *port;
 	
-	pthread_t *gps_thread;
 	gps_data *gpsdata;
 	
 	gps_fix *last_fix;
@@ -344,7 +343,7 @@
 }
 
 static void 
-gpsd_callback (struct gps_data_t *gpsdata, char *message, size_t len, int level)
+gpsd_raw_hook (struct gps_data_t *gpsdata, char *message, size_t len)
 {
 	char *tag_str = gpsd->gpsdata->tag;
 	NmeaTag nmea_tag = NMEA_NONE;
@@ -369,7 +368,6 @@
 {
 	if (self->gpsdata) {
 		gps_close (self->gpsdata);
-		g_free (self->gps_thread);
 		self->gpsdata = NULL;
 	}
 }
@@ -379,8 +377,8 @@
 {
 	self->gpsdata = gps_open (self->host, self->port);
 	if (self->gpsdata) {
-		/* This can block for some time if device is not available */
-		gps_set_callback (self->gpsdata, gpsd_callback, self->gps_thread);
+		gps_stream(self->gpsdata, WATCH_ENABLE | WATCH_NMEA | POLL_NONBLOCK, NULL);
+		gps_set_raw_hook (self->gpsdata, gpsd_raw_hook);
 		return TRUE;
 	} else {
 		g_warning ("gps_open() failed, is gpsd running (host=%s,port=%s)?", self->host, self->port);
@@ -388,11 +386,24 @@
 	}
 }
 
+gboolean
+gpsd_poll(gpointer data)
+{
+	GeoclueGpsd *self = (GeoclueGpsd*)data;
+	if (self->gpsdata) {
+		if (gps_poll(self->gpsdata) < 0) {
+			geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ERROR);
+			geoclue_gpsd_stop_gpsd(self);
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+
 static void
 geoclue_gpsd_init (GeoclueGpsd *self)
 {
 	self->gpsdata = NULL;
-	self->gps_thread = g_new0 (pthread_t, 1);
 	self->last_fix = g_new0 (gps_fix, 1);
 	
 	self->last_pos_fields = GEOCLUE_POSITION_FIELDS_NONE;
@@ -475,6 +486,8 @@
 	gpsd = g_object_new (GEOCLUE_TYPE_GPSD, NULL);
 	
 	gpsd->loop = g_main_loop_new (NULL, TRUE);
+	g_timeout_add(500, gpsd_poll, (gpointer)gpsd);
+	
 	g_main_loop_run (gpsd->loop);
 	
 	g_main_loop_unref (gpsd->loop);
