[Cbe-oss-dev] [PATCH] libspe2: Remove spe_fds_refcount

Kazunori Asayama asayama at sm.sony.co.jp
Thu Nov 16 17:19:41 EST 2006


Attached is a patch to clean up the spebase part of libspe2.

This patch removes code related to spe_fds_refcount because of
following reasons:

  - this mechanism is no longer used.
    (and I also think that it should not be used for performance
    reason, i.e. to avoid frequently closing and reopening files)
  - this implementation does not work correctly.

--
(ASAYAMA Kazunori
  (asayama at sm.sony.co.jp))
t
-------------- next part --------------
Index: libspe2/spebase/create.c
===================================================================
--- libspe2.orig/spebase/create.c
+++ libspe2/spebase/create.c
@@ -69,28 +69,14 @@ int setsignotify(int dir, const char* fi
 int open_if_closed(struct spe_context *spe, enum fd_name fdesc)
 {
 	if (spe->base_private->spe_fds_array[(int)fdesc] != -1) { // already open
-		spe->base_private->spe_fds_refcount[(int)fdesc]++;
 		return spe->base_private->spe_fds_array[(int)fdesc];
 	}
 	
 	spe->base_private->spe_fds_array[(int)fdesc] = openat(spe->base_private->fd_spe_dir, spe_fd_name[(int)fdesc], spe_fd_mode[(int)fdesc]);
-	if (spe->base_private->spe_fds_array[(int)fdesc] > 0)
-		spe->base_private->spe_fds_refcount[(int)fdesc]++;
 	
 	return spe->base_private->spe_fds_array[(int)fdesc];
 }
 
-void close_if_open(struct spe_context *spe, enum fd_name fdesc)
-{
-	if (spe->base_private->spe_fds_array[(int)fdesc] != -1 &&
-		spe->base_private->spe_fds_refcount[(int)fdesc] == 1){
-		spe->base_private->spe_fds_refcount[(int)fdesc]--;
-		close(spe->base_private->spe_fds_array[(int)fdesc]);
-	}else if (spe->base_private->spe_fds_refcount[(int)fdesc] > 0) {
-		spe->base_private->spe_fds_refcount[(int)fdesc]--;
-	}
-}
-
 spe_context_ptr_t _base_spe_context_create(unsigned int flags, spe_gang_context_ptr_t gctx)
 {
 	char pathname[256];
Index: libspe2/spebase/spebase.h
===================================================================
--- libspe2.orig/spebase/spebase.h
+++ libspe2/spebase/spebase.h
@@ -54,7 +54,6 @@ struct spe_context_base_priv {
 	
 	/* SPE Mailbox and Signal fds */
 	int spe_fds_array[NUM_MBOX_FDS];
-	int spe_fds_refcount[NUM_MBOX_FDS];
 	
 	/* SPE MFC Unit fd */
 	//int	fd_mfc;
Index: libspe2/spebase/create.h
===================================================================
--- libspe2.orig/spebase/create.h
+++ libspe2/spebase/create.h
@@ -26,6 +26,5 @@ extern void *mapfileat( int dir, const c
 extern int setsignotify(int dir, const char* filename);
 //extern void open_if_closed(struct spe_context *spe, int * fd, const char* filename, int oflag);
 extern int open_if_closed(struct spe_context *spe, enum fd_name fdesc);
-extern void close_if_open(struct spe_context *spe, enum fd_name fdesc);
 
 #endif


More information about the cbe-oss-dev mailing list