~ubuntu-branches/ubuntu/lucid/php5/lucid

« back to all changes in this revision

Viewing changes to main/streams/streams.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-03-16 09:09:50 UTC
  • mfrom: (1.1.18 upstream) (0.3.10 sid)
  • Revision ID: james.westby@ubuntu.com-20100316090950-e36m0pzranoixifd
Tags: 5.3.2-1ubuntu1
* Merge from debian unstable: 
  - debian/control:
    * Dropped firebird2.1-dev, libc-client-dev, libmcrypt-dev as it is in universe.
    * Dropped libmysqlclient15-dev, build against mysql 5.1.
    * Dropped libcurl-dev not in the archive.
    * Suggest php5-suhosin rather than recommends.
    * Dropped php5-imap, php5-interbase, php5-mcrypt since we have versions already in
      universe.
    * Dropped libonig-dev and libqgdbm since its in universe. (will be re-added in lucid+1)
    * Dropped locales-all.
  - modulelist: Drop imap, interbase, and mcrypt.
  - debian/rules:
    * Dropped building of mcrypt, imap, and interbase.
    * Install apport hook for php5.
  - Dropped debian/patches/libedit_is_editline.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
   +----------------------------------------------------------------------+
3
3
   | PHP Version 5                                                        |
4
4
   +----------------------------------------------------------------------+
5
 
   | Copyright (c) 1997-2009 The PHP Group                                |
 
5
   | Copyright (c) 1997-2010 The PHP Group                                |
6
6
   +----------------------------------------------------------------------+
7
7
   | This source file is subject to version 3.01 of the PHP license,      |
8
8
   | that is bundled with this package in the file LICENSE, and is        |
19
19
   +----------------------------------------------------------------------+
20
20
 */
21
21
 
22
 
/* $Id: streams.c 280678 2009-05-17 14:58:10Z lbarnaud $ */
 
22
/* $Id: streams.c 294550 2010-02-05 00:39:31Z pajoye $ */
23
23
 
24
24
#define _GNU_SOURCE
25
25
#include "php.h"
1396
1396
        /* we've got at least 1 byte to read. 
1397
1397
         * less than 1 is an error */
1398
1398
 
1399
 
        if (haveread > 0) {
 
1399
        if (haveread > 0 || src->eof) {
1400
1400
                return SUCCESS;
1401
1401
        }
1402
1402
        return FAILURE;
1858
1858
                        php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC,
1859
1859
                                        "wrapper does not support stream open");
1860
1860
                } else {
1861
 
                        /* refcount++ to make sure the context doesn't get destroyed 
1862
 
                         * if open() fails and stream is closed */
1863
 
                        if (context) {
1864
 
                                zend_list_addref(context->rsrc_id);
1865
 
                        }
1866
 
 
1867
1861
                        stream = wrapper->wops->stream_opener(wrapper,
1868
1862
                                path_to_open, mode, options ^ REPORT_ERRORS,
1869
1863
                                opened_path, context STREAMS_REL_CC TSRMLS_CC);
1870
 
 
1871
 
                        /* if open() succeeded and context was not used, do refcount-- 
1872
 
                         * XXX if a wrapper didn't actually use context (no way to know that) 
1873
 
                         * and open() failed, refcount will stay increased */
1874
 
                        if (context && stream && !stream->context) {
1875
 
                                zend_list_delete(context->rsrc_id);
1876
 
                        }
1877
1864
                }
1878
1865
 
1879
1866
                /* if the caller asked for a persistent stream but the wrapper did not
1974
1961
PHPAPI php_stream_context *php_stream_context_set(php_stream *stream, php_stream_context *context)
1975
1962
{
1976
1963
        php_stream_context *oldcontext = stream->context;
 
1964
        TSRMLS_FETCH();
 
1965
 
1977
1966
        stream->context = context;
 
1967
 
 
1968
        if (context) {
 
1969
                zend_list_addref(context->rsrc_id);
 
1970
        }
 
1971
        if (oldcontext) {
 
1972
                zend_list_delete(oldcontext->rsrc_id);
 
1973
        }
 
1974
 
1978
1975
        return oldcontext;
1979
1976
}
1980
1977