diff options
author | unknown <aivanov@mysql.com> | 2006-03-10 19:22:21 +0300 |
---|---|---|
committer | unknown <aivanov@mysql.com> | 2006-03-10 19:22:21 +0300 |
commit | 142c4132531e418f97443186b7c2c319ffa1d005 (patch) | |
tree | 8105d79f7267d8af93861befd1899063f1ad42c2 /storage/innobase/os | |
parent | 629ea1ca075afab3cd1edb9b66f4d78587e3d9e9 (diff) | |
download | mariadb-git-142c4132531e418f97443186b7c2c319ffa1d005.tar.gz |
Applied innodb-5.1-ss269 snapshot.
Fixed BUGS:
#3300: "UPDATE statement with no index column in where condition locks
all rows"
Implement semi-consistent read to reduce lock conflicts at the cost
of breaking serializability.
ha_innobase::unlock_row(): reset the "did semi consistent read" flag
ha_innobase::was_semi_consistent_read(),
ha_innobase::try_semi_consistent_read(): new methods
row_prebuilt_t, row_create_prebuilt(): add field row_read_type for
keeping track of semi-consistent reads
row_vers_build_for_semi_consistent_read(),
row_sel_build_committed_vers_for_mysql(): new functions
row_search_for_mysql(): implement semi-consistent reads
#9802: "Foreign key checks disallow alter table".
Added test cases.
#12456: "Cursor shows incorrect data - DML does not affect,
probably caching"
This patch implements a high-granularity read view to be used with
cursors. In this high-granularity consistent read view modifications
done by the creating transaction after the cursor is created or
future transactions are not visible. But those modifications that
transaction did before the cursor was created are visible.
#12701: "Support >4GB buffer pool and log files on 64-bit Windows"
Do not call os_file_create_tmpfile() at runtime. Instead, create all
tempfiles at startup and guard access to them with mutexes.
#13778: "If FOREIGN_KEY_CHECKS=0, one can create inconsistent FOREIGN KEYs".
When FOREIGN_KEY_CHECKS=0 we still need to check that datatypes between
foreign key references are compatible.
#14189: "VARBINARY and BINARY variables: trailing space ignored with InnoDB"
innobase_init(): Assert that
DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number.
dtype_get_pad_char(): Do not pad VARBINARY or BINARY columns.
row_ins_cascade_calc_update_vec(): Refuse ON UPDATE CASCADE when trying
to change the length of a VARBINARY column that refers to or is referenced
by a BINARY column. BINARY columns are no longer padded on comparison,
and thus they cannot be padded on storage either.
#14747: "Race condition can cause btr_search_drop_page_hash_index() to crash"
Note that buf_block_t::index should be protected by btr_search_latch
or an s-latch or x-latch on the index page.
btr_search_drop_page_hash_index(): Read block->index while holding
btr_search_latch and use the cached value in the loop. Remove some
redundant assertions.
#15108: "mysqld crashes when innodb_log_file_size is set > 4G"
#15308: "Problem of Order with Enum Column in Primary Key"
#15550: "mysqld crashes in printing a FOREIGN KEY error in InnoDB"
row_ins_foreign_report_add_err(): When printing the parent record,
use the index in the parent table rather than the index in the child table.
#15653: "Slow inserts to InnoDB if many thousands of .ibd files"
Keep track on unflushed modifications to file spaces. When there are tens
of thousands of file spaces, flushing all files in fil_flush_file_spaces()
would be very slow.
fil_flush_file_spaces(): Only flush unflushed file spaces.
fil_space_t, fil_system_t: Add a list of unflushed spaces.
#15991: "innodb-file-per-table + symlink database + rename = cr"
os_file_handle_error(): Map the error codes EXDEV, ENOTDIR, and EISDIR
to the new code OS_FILE_PATH_ERROR. Treat this code as OS_FILE_PATH_ERROR.
This fixes the crash on RENAME TABLE when the .ibd file is a symbolic link
to a different file system.
#16157: "InnoDB crashes when main location settings are empty"
This patch is from Heikki.
#16298: "InnoDB segfaults in INSERTs in upgrade of 4.0 -> 5.0 tables
with VARCHAR BINARY"
dict_load_columns(): Set the charset-collation code
DATA_MYSQL_BINARY_CHARSET_COLL for those binary string columns
that lack a charset-collation code, i.e., the tables were created
with an older version of MySQL/InnoDB than 4.1.2.
#16229: "MySQL/InnoDB uses full explicit table locks in trigger processing"
Take a InnoDB table lock only if user has explicitly requested a table
lock. Added some additional comments to store_lock() and external_lock().
#16387: "InnoDB crash when dropping a foreign key <table>_ibfk_0"
Do not mistake TABLENAME_ibfk_0 for auto-generated id.
dict_table_get_highest_foreign_id(): Ignore foreign constraint
identifiers starting with the pattern TABLENAME_ibfk_0.
#16582: "InnoDB: Error in an adaptive hash index pointer to page"
Account for a race condition when dropping the adaptive hash index
for a B-tree page.
btr_search_drop_page_hash_index(): Retry the operation if a hash index
with different parameters was built meanwhile. Add diagnostics for the
case that hash node pointers to the page remain.
btr_search_info_update_hash(), btr_search_info_update_slow():
Document the parameter "info" as in/out.
#16814: "SHOW INNODB STATUS format error in LATEST FOREIGN KEY ERROR
section"
Add a missing newline to the LAST FOREIGN KEY ERROR section in SHOW
INNODB STATUS output.
dict_foreign_error_report(): Always print a newline after invoking
dict_print_info_on_foreign_key_in_create_format().
#16827: "Better InnoDB error message if ibdata files omitted from my.cnf"
#17126: "CHECK TABLE on InnoDB causes a short hang during check of adaptive
hash"
CHECK TABLE blocking other queries, by releasing the btr_search_latch
periodically during the adaptive hash table validation.
#17405: "Valgrind: conditional jump or move depends on unititialised values"
buf_block_init(): Reset magic_n, buf_fix_count and io_fix to avoid
testing uninitialized variables.
mysql-test/r/innodb.result:
Applied innodb-5.1-ss269 snapshot.
mysql-test/t/innodb.test:
Applied innodb-5.1-ss269 snapshot.
sql/ha_innodb.cc:
Applied innodb-5.1-ss269 snapshot.
sql/ha_innodb.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/btr/btr0btr.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/btr/btr0cur.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/btr/btr0pcur.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/btr/btr0sea.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/buf/buf0buf.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/buf/buf0flu.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/buf/buf0lru.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/buf/buf0rea.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/data/data0data.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/data/data0type.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/dict/dict0boot.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/dict/dict0crea.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/dict/dict0dict.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/dict/dict0load.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/dict/dict0mem.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/dyn/dyn0dyn.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/eval/eval0eval.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/eval/eval0proc.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/fil/fil0fil.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/fsp/fsp0fsp.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/fut/fut0lst.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ha/ha0ha.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ha/hash0hash.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ibuf/ibuf0ibuf.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0btr.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0btr.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0cur.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0cur.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0pcur.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0pcur.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0sea.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0sea.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/buf0buf.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/buf0buf.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/buf0flu.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/buf0flu.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/buf0lru.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/data0data.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/data0data.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/data0type.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/data0type.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/db0err.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0boot.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0boot.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0crea.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0dict.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0dict.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0load.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0mem.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dyn0dyn.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dyn0dyn.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/eval0eval.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/eval0eval.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/eval0proc.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/eval0proc.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/fil0fil.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/fsp0fsp.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/fut0lst.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ha0ha.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/hash0hash.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/hash0hash.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ibuf0ibuf.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ibuf0ibuf.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/lock0lock.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/lock0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/log0log.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/log0log.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/log0recv.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mach0data.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mach0data.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mem0dbg.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mem0dbg.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mem0mem.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mem0mem.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mem0pool.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mtr0log.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mtr0mtr.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mtr0mtr.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/os0file.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/os0proc.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/os0sync.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/os0sync.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/os0thread.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/page0cur.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/page0cur.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/page0page.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/page0page.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/page0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/pars0grm.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/pars0opt.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/pars0pars.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/pars0sym.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/pars0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/que0que.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/que0que.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/que0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/read0read.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/read0read.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/rem0cmp.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/rem0cmp.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/rem0rec.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/rem0rec.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0ins.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0mysql.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0purge.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0row.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0row.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0sel.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0sel.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0uins.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0umod.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0undo.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0upd.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0upd.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0vers.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/srv0srv.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/srv0start.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/sync0arr.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/sync0rw.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/sync0rw.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/sync0sync.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/sync0sync.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0purge.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0purge.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0rec.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0roll.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0rseg.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0rseg.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0sys.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0sys.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0trx.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0trx.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0undo.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0undo.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0xa.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/univ.i:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/usr0sess.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/usr0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0byte.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0byte.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0dbg.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0lst.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0mem.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0mem.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0rnd.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0rnd.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0sort.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0ut.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0ut.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/lock/lock0lock.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/log/log0log.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/log/log0recv.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/mach/mach0data.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/mem/mem0dbg.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/mem/mem0mem.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/mem/mem0pool.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/mtr/mtr0log.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/mtr/mtr0mtr.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/os/os0file.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/os/os0proc.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/os/os0sync.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/os/os0thread.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/page/page0cur.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/page/page0page.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/lexyy.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0grm.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0grm.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0grm.y:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0lex.l:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0opt.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0pars.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0sym.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/que/que0que.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/read/read0read.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/rem/rem0cmp.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/rem/rem0rec.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0ins.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0mysql.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0purge.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0row.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0sel.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0uins.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0umod.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0undo.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0upd.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0vers.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/srv/srv0que.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/srv/srv0srv.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/srv/srv0start.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/sync/sync0arr.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/sync/sync0rw.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/sync/sync0sync.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/thr/thr0loc.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0purge.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0rec.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0roll.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0rseg.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0sys.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0trx.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0undo.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/usr/usr0sess.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ut/ut0byte.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ut/ut0dbg.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ut/ut0mem.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ut/ut0rnd.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ut/ut0ut.c:
Applied innodb-5.1-ss269 snapshot.
mysql-test/r/innodb_unsafe_binlog.result:
New BitKeeper file ``mysql-test/r/innodb_unsafe_binlog.result''
mysql-test/t/innodb_unsafe_binlog-master.opt:
New BitKeeper file ``mysql-test/t/innodb_unsafe_binlog-master.opt''
mysql-test/t/innodb_unsafe_binlog.test:
New BitKeeper file ``mysql-test/t/innodb_unsafe_binlog.test''
storage/innobase/pars/make_bison.sh:
New BitKeeper file ``storage/innobase/pars/make_bison.sh''
Diffstat (limited to 'storage/innobase/os')
-rw-r--r-- | storage/innobase/os/os0file.c | 1020 | ||||
-rw-r--r-- | storage/innobase/os/os0proc.c | 222 | ||||
-rw-r--r-- | storage/innobase/os/os0sync.c | 99 | ||||
-rw-r--r-- | storage/innobase/os/os0thread.c | 69 |
4 files changed, 706 insertions, 704 deletions
diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index 20a3303d12d..d10bdccbd2b 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -93,7 +93,7 @@ struct os_aio_slot_struct{ which pending aio operation was completed */ #ifdef WIN_ASYNC_IO - os_event_t event; /* event object we need in the + os_event_t event; /* event object we need in the OVERLAPPED struct */ OVERLAPPED control; /* Windows control block for the aio request */ @@ -121,9 +121,9 @@ struct os_aio_array_struct{ separately for any one of the segments. */ ulint n_reserved;/* Number of reserved slots in the aio array outside the ibuf segment */ - os_aio_slot_t* slots; /* Pointer to the slots in the array */ + os_aio_slot_t* slots; /* Pointer to the slots in the array */ #ifdef __WIN__ - os_native_event_t* native_events; + os_native_event_t* native_events; /* Pointer to an array of OS native event handles where we copied the handles from slots, in the same order. This can be used @@ -160,15 +160,12 @@ time_t os_last_printout; ibool os_has_said_disk_full = FALSE; -/* The mutex protecting the following counts of pending pread and pwrite -operations */ +/* The mutex protecting the following counts of pending I/O operations */ static os_mutex_t os_file_count_mutex; ulint os_file_n_pending_preads = 0; ulint os_file_n_pending_pwrites = 0; - -/* These are not protected by any mutex */ -ulint os_n_pending_writes = 0; -ulint os_n_pending_reads = 0; +ulint os_n_pending_writes = 0; +ulint os_n_pending_reads = 0; /*************************************************************************** Gets the operating system version. Currently works only on Windows. */ @@ -176,33 +173,33 @@ Gets the operating system version. Currently works only on Windows. */ ulint os_get_os_version(void) /*===================*/ - /* out: OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000 */ + /* out: OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000 */ { #ifdef __WIN__ - OSVERSIONINFO os_info; + OSVERSIONINFO os_info; - os_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + os_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); ut_a(GetVersionEx(&os_info)); - if (os_info.dwPlatformId == VER_PLATFORM_WIN32s) { - return(OS_WIN31); - } else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { - return(OS_WIN95); - } else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_NT) { + if (os_info.dwPlatformId == VER_PLATFORM_WIN32s) { + return(OS_WIN31); + } else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { + return(OS_WIN95); + } else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_NT) { if (os_info.dwMajorVersion <= 4) { - return(OS_WINNT); - } else { + return(OS_WINNT); + } else { return(OS_WIN2000); - } - } else { - ut_error; - return(0); - } + } + } else { + ut_error; + return(0); + } #else - ut_error; + ut_error; - return(0); + return(0); #endif } @@ -227,10 +224,10 @@ os_file_get_last_error( err = (ulint) GetLastError(); if (report_all_errors - || (err != ERROR_DISK_FULL && err != ERROR_FILE_EXISTS)) { + || (err != ERROR_DISK_FULL && err != ERROR_FILE_EXISTS)) { ut_print_timestamp(stderr); - fprintf(stderr, + fprintf(stderr, " InnoDB: Operating system error number %lu in a file operation.\n", (ulong) err); if (err == ERROR_PATH_NOT_FOUND) { @@ -246,7 +243,7 @@ os_file_get_last_error( fprintf(stderr, "InnoDB: The error means mysqld does not have the access rights to\n" "InnoDB: the directory. It may also be you have created a subdirectory\n" - "InnoDB: of the same name as a data file.\n"); + "InnoDB: of the same name as a data file.\n"); } else { fprintf(stderr, "InnoDB: Some operating system error numbers are described at\n" @@ -270,16 +267,16 @@ os_file_get_last_error( err = (ulint) errno; if (report_all_errors - || (err != ENOSPC && err != EEXIST)) { + || (err != ENOSPC && err != EEXIST)) { ut_print_timestamp(stderr); - fprintf(stderr, + fprintf(stderr, " InnoDB: Operating system error number %lu in a file operation.\n", (ulong) err); if (err == ENOENT) { fprintf(stderr, "InnoDB: The error means the system cannot find the path specified.\n"); - + if (srv_is_being_started) { fprintf(stderr, "InnoDB: If you are installing InnoDB, remember that you must create\n" @@ -314,6 +311,8 @@ os_file_get_last_error( return(OS_FILE_NOT_FOUND); } else if (err == EEXIST) { return(OS_FILE_ALREADY_EXISTS); + } else if (err == EXDEV || err == ENOTDIR || err == EISDIR) { + return(OS_FILE_PATH_ERROR); } else { return(100 + err); } @@ -334,7 +333,7 @@ os_file_handle_error( ulint err; err = os_file_get_last_error(FALSE); - + if (err == OS_FILE_DISK_FULL) { /* We only print a warning about disk full once */ @@ -342,7 +341,7 @@ os_file_handle_error( return(FALSE); } - + if (name) { ut_print_timestamp(stderr); fprintf(stderr, @@ -350,7 +349,7 @@ os_file_handle_error( } ut_print_timestamp(stderr); - fprintf(stderr, + fprintf(stderr, " InnoDB: Disk is full. Try to clean the disk to free space.\n"); os_has_said_disk_full = TRUE; @@ -363,16 +362,17 @@ os_file_handle_error( return(TRUE); - } else if (err == OS_FILE_ALREADY_EXISTS) { + } else if (err == OS_FILE_ALREADY_EXISTS + || err == OS_FILE_PATH_ERROR) { return(FALSE); } else { - if (name) { - fprintf(stderr, "InnoDB: File name %s\n", name); - } - + if (name) { + fprintf(stderr, "InnoDB: File name %s\n", name); + } + fprintf(stderr, "InnoDB: File operation call: '%s'.\n", - operation); + operation); fprintf(stderr, "InnoDB: Cannot continue operation.\n"); fflush(stderr); @@ -380,7 +380,7 @@ os_file_handle_error( exit(1); } - return(FALSE); + return(FALSE); } #undef USE_FILE_LOCK @@ -438,7 +438,7 @@ os_file_handle_error_no_exit( ulint err; err = os_file_get_last_error(FALSE); - + if (err == OS_FILE_DISK_FULL) { /* We only print a warning about disk full once */ @@ -446,7 +446,7 @@ os_file_handle_error_no_exit( return(FALSE); } - + if (name) { ut_print_timestamp(stderr); fprintf(stderr, @@ -454,7 +454,7 @@ os_file_handle_error_no_exit( } ut_print_timestamp(stderr); - fprintf(stderr, + fprintf(stderr, " InnoDB: Disk is full. Try to clean the disk to free space.\n"); os_has_said_disk_full = TRUE; @@ -467,16 +467,17 @@ os_file_handle_error_no_exit( return(TRUE); - } else if (err == OS_FILE_ALREADY_EXISTS) { + } else if (err == OS_FILE_ALREADY_EXISTS + || err == OS_FILE_PATH_ERROR) { return(FALSE); } else { - if (name) { - fprintf(stderr, "InnoDB: File name %s\n", name); - } - + if (name) { + fprintf(stderr, "InnoDB: File name %s\n", name); + } + fprintf(stderr, "InnoDB: File operation call: '%s'.\n", - operation); + operation); return (FALSE); } @@ -501,7 +502,8 @@ os_io_init_simple(void) #if !defined(UNIV_HOTBACKUP) && !defined(__NETWARE__) /************************************************************************* -Creates a temporary file. This function is defined in ha_innodb.cc. */ +Creates a temporary file that will be deleted on close. +This function is defined in ha_innodb.cc. */ int innobase_mysql_tmpfile(void); @@ -510,68 +512,46 @@ innobase_mysql_tmpfile(void); #endif /* !UNIV_HOTBACKUP && !__NETWARE__ */ /*************************************************************************** -Creates a temporary file. */ +Creates a temporary file. This function is like tmpfile(3), but +the temporary file is created in the MySQL temporary directory. +On Netware, this function is like tmpfile(3), because the C run-time +library of Netware does not expose the delete-on-close flag. */ FILE* os_file_create_tmpfile(void) /*========================*/ /* out: temporary file handle, or NULL on error */ { -#ifdef __NETWARE__ +#ifdef UNIV_HOTBACKUP + ut_error; + + return(NULL); +#else +# ifdef __NETWARE__ FILE* file = tmpfile(); -#else /* __NETWARE__ */ +# else /* __NETWARE__ */ FILE* file = NULL; - int fd = -1; -# ifdef UNIV_HOTBACKUP - int tries; - for (tries = 10; tries--; ) { - char* name = tempnam(fil_path_to_mysql_datadir, "ib"); - if (!name) { - break; - } - - fd = open(name, -# ifdef __WIN__ - O_SEQUENTIAL | O_SHORT_LIVED | O_TEMPORARY | -# endif /* __WIN__ */ - O_CREAT | O_EXCL | O_RDWR, - S_IREAD | S_IWRITE); - if (fd >= 0) { -# ifndef __WIN__ - unlink(name); -# endif /* !__WIN__ */ - free(name); - break; - } - - ut_print_timestamp(stderr); - fprintf(stderr, " InnoDB: Warning: " - "unable to create temporary file %s, retrying\n", - name); - free(name); - } -# else /* UNIV_HOTBACKUP */ - fd = innobase_mysql_tmpfile(); -# endif /* UNIV_HOTBACKUP */ + int fd = innobase_mysql_tmpfile(); if (fd >= 0) { file = fdopen(fd, "w+b"); } -#endif /* __NETWARE__ */ +# endif /* __NETWARE__ */ if (!file) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: unable to create temporary file;" " errno: %d\n", errno); -#ifndef __NETWARE__ +# ifndef __NETWARE__ if (fd >= 0) { close(fd); } -#endif /* !__NETWARE__ */ +# endif /* !__NETWARE__ */ } return(file); +#endif /* UNIV_HOTBACKUP */ } /*************************************************************************** @@ -595,7 +575,7 @@ os_file_opendir( { os_file_dir_t dir; #ifdef __WIN__ - LPWIN32_FIND_DATA lpFindFileData; + LPWIN32_FIND_DATA lpFindFileData; char path[OS_FILE_MAX_PATH + 3]; ut_a(strlen(dirname) < OS_FILE_MAX_PATH); @@ -616,18 +596,18 @@ os_file_opendir( if (dir == INVALID_HANDLE_VALUE) { if (error_is_fatal) { - os_file_handle_error(dirname, "opendir"); + os_file_handle_error(dirname, "opendir"); } return(NULL); } - return(dir); + return(dir); #else dir = opendir(dirname); if (dir == NULL && error_is_fatal) { - os_file_handle_error(dirname, "opendir"); + os_file_handle_error(dirname, "opendir"); } return(dir); @@ -649,19 +629,19 @@ os_file_closedir( ret = FindClose(dir); if (!ret) { - os_file_handle_error_no_exit(NULL, "closedir"); - + os_file_handle_error_no_exit(NULL, "closedir"); + return(-1); } - + return(0); #else int ret; - + ret = closedir(dir); if (ret) { - os_file_handle_error_no_exit(NULL, "closedir"); + os_file_handle_error_no_exit(NULL, "closedir"); } return(ret); @@ -690,18 +670,18 @@ next_file: ret = FindNextFile(dir, lpFindFileData); if (ret) { - ut_a(strlen((char *) lpFindFileData->cFileName) < OS_FILE_MAX_PATH); + ut_a(strlen((char *) lpFindFileData->cFileName) < OS_FILE_MAX_PATH); if (strcmp((char *) lpFindFileData->cFileName, ".") == 0 - || strcmp((char *) lpFindFileData->cFileName, "..") == 0) { + || strcmp((char *) lpFindFileData->cFileName, "..") == 0) { - goto next_file; + goto next_file; } strcpy(info->name, (char *) lpFindFileData->cFileName); info->size = (ib_longlong)(lpFindFileData->nFileSizeLow) - + (((ib_longlong)(lpFindFileData->nFileSizeHigh)) << 32); + + (((ib_longlong)(lpFindFileData->nFileSizeHigh)) << 32); if (lpFindFileData->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { @@ -712,7 +692,7 @@ http://www.mysql.com/doc/en/Windows_symbolic_links.html */ info->type = OS_FILE_TYPE_LINK; } else if (lpFindFileData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - info->type = OS_FILE_TYPE_DIR; + info->type = OS_FILE_TYPE_DIR; } else { /* It is probably safest to assume that all other file types are normal. Better to check them rather @@ -761,7 +741,7 @@ next_file: if (ent == NULL) { /* End of directory */ - + return(1); } @@ -784,7 +764,7 @@ next_file: strcpy(info->name, ent->d_name); full_path = ut_malloc(strlen(dirname) + strlen(ent->d_name) + 10); - + sprintf(full_path, "%s/%s", dirname, ent->d_name); ret = stat(full_path, &statinfo); @@ -802,13 +782,13 @@ next_file: if (S_ISDIR(statinfo.st_mode)) { info->type = OS_FILE_TYPE_DIR; } else if (S_ISLNK(statinfo.st_mode)) { - info->type = OS_FILE_TYPE_LINK; + info->type = OS_FILE_TYPE_LINK; } else if (S_ISREG(statinfo.st_mode)) { - info->type = OS_FILE_TYPE_FILE; + info->type = OS_FILE_TYPE_FILE; } else { - info->type = OS_FILE_TYPE_UNKNOWN; + info->type = OS_FILE_TYPE_UNKNOWN; } - + ut_free(full_path); return(0); @@ -833,7 +813,7 @@ os_file_create_directory( { #ifdef __WIN__ BOOL rcode; - + rcode = CreateDirectory((LPCTSTR) pathname, NULL); if (!(rcode != 0 || (GetLastError() == ERROR_ALREADY_EXISTS && !fail_if_exists))) { @@ -842,7 +822,7 @@ os_file_create_directory( return(FALSE); } - + return (TRUE); #else int rcode; @@ -855,9 +835,9 @@ os_file_create_directory( return(FALSE); } - + return (TRUE); -#endif +#endif } /******************************************************************** @@ -875,7 +855,7 @@ os_file_create_simple( opened (if does not exist, error), or OS_FILE_CREATE if a new file is created (if exists, error), or - OS_FILE_CREATE_PATH if new file + OS_FILE_CREATE_PATH if new file (if exists, error) and subdirectories along its path are created (if needed)*/ ulint access_type,/* in: OS_FILE_READ_ONLY or @@ -888,22 +868,22 @@ os_file_create_simple( DWORD access; DWORD attributes = 0; ibool retry; - -try_again: + +try_again: ut_a(name); if (create_mode == OS_FILE_OPEN) { create_flag = OPEN_EXISTING; } else if (create_mode == OS_FILE_CREATE) { create_flag = CREATE_NEW; - } else if (create_mode == OS_FILE_CREATE_PATH) { - /* create subdirs along the path if needed */ - *success = os_file_create_subdirs_if_needed(name); - if (!*success) { - ut_error; - } - create_flag = CREATE_NEW; - create_mode = OS_FILE_CREATE; + } else if (create_mode == OS_FILE_CREATE_PATH) { + /* create subdirs along the path if needed */ + *success = os_file_create_subdirs_if_needed(name); + if (!*success) { + ut_error; + } + create_flag = CREATE_NEW; + create_mode = OS_FILE_CREATE; } else { create_flag = 0; ut_error; @@ -946,8 +926,8 @@ try_again: os_file_t file; int create_flag; ibool retry; - -try_again: + +try_again: ut_a(name); if (create_mode == OS_FILE_OPEN) { @@ -958,26 +938,26 @@ try_again: } } else if (create_mode == OS_FILE_CREATE) { create_flag = O_RDWR | O_CREAT | O_EXCL; - } else if (create_mode == OS_FILE_CREATE_PATH) { - /* create subdirs along the path if needed */ - *success = os_file_create_subdirs_if_needed(name); - if (!*success) { - return (-1); - } - create_flag = O_RDWR | O_CREAT | O_EXCL; - create_mode = OS_FILE_CREATE; + } else if (create_mode == OS_FILE_CREATE_PATH) { + /* create subdirs along the path if needed */ + *success = os_file_create_subdirs_if_needed(name); + if (!*success) { + return (-1); + } + create_flag = O_RDWR | O_CREAT | O_EXCL; + create_mode = OS_FILE_CREATE; } else { create_flag = 0; ut_error; } if (create_mode == OS_FILE_CREATE) { - file = open(name, create_flag, S_IRUSR | S_IWUSR + file = open(name, create_flag, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); - } else { - file = open(name, create_flag); - } - + } else { + file = open(name, create_flag); + } + if (file == -1) { *success = FALSE; @@ -998,7 +978,7 @@ try_again: *success = TRUE; } - return(file); + return(file); #endif /* __WIN__ */ } @@ -1029,7 +1009,7 @@ os_file_create_simple_no_error_handling( DWORD access; DWORD attributes = 0; DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE; - + ut_a(name); if (create_mode == OS_FILE_OPEN) { @@ -1048,7 +1028,7 @@ os_file_create_simple_no_error_handling( } else if (access_type == OS_FILE_READ_ALLOW_DELETE) { access = GENERIC_READ; share_mode = FILE_SHARE_DELETE | FILE_SHARE_READ - | FILE_SHARE_WRITE; /* A backup program has to give + | FILE_SHARE_WRITE; /* A backup program has to give mysqld the maximum freedom to do what it likes with the file */ @@ -1075,7 +1055,7 @@ os_file_create_simple_no_error_handling( #else /* __WIN__ */ os_file_t file; int create_flag; - + ut_a(name); if (create_mode == OS_FILE_OPEN) { @@ -1092,12 +1072,12 @@ os_file_create_simple_no_error_handling( } if (create_mode == OS_FILE_CREATE) { - file = open(name, create_flag, S_IRUSR | S_IWUSR + file = open(name, create_flag, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); - } else { - file = open(name, create_flag); - } - + } else { + file = open(name, create_flag); + } + if (file == -1) { *success = FALSE; #ifdef USE_FILE_LOCK @@ -1111,7 +1091,7 @@ os_file_create_simple_no_error_handling( *success = TRUE; } - return(file); + return(file); #endif /* __WIN__ */ } @@ -1150,7 +1130,7 @@ os_file_create( DWORD create_flag; DWORD attributes; ibool retry; -try_again: +try_again: ut_a(name); if (create_mode == OS_FILE_OPEN_RAW) { @@ -1176,27 +1156,27 @@ try_again: if (os_aio_use_native_aio) { attributes = attributes | FILE_FLAG_OVERLAPPED; } -#endif +#endif #ifdef UNIV_NON_BUFFERED_IO if (type == OS_LOG_FILE && srv_flush_log_at_trx_commit == 2) { - /* Do not use unbuffered i/o to log files because - value 2 denotes that we do not flush the log at every - commit, but only once per second */ + /* Do not use unbuffered i/o to log files because + value 2 denotes that we do not flush the log at every + commit, but only once per second */ } else if (srv_win_file_flush_method == - SRV_WIN_IO_UNBUFFERED) { - attributes = attributes | FILE_FLAG_NO_BUFFERING; + SRV_WIN_IO_UNBUFFERED) { + attributes = attributes | FILE_FLAG_NO_BUFFERING; } #endif } else if (purpose == OS_FILE_NORMAL) { - attributes = 0; + attributes = 0; #ifdef UNIV_NON_BUFFERED_IO if (type == OS_LOG_FILE && srv_flush_log_at_trx_commit == 2) { - /* Do not use unbuffered i/o to log files because - value 2 denotes that we do not flush the log at every - commit, but only once per second */ + /* Do not use unbuffered i/o to log files because + value 2 denotes that we do not flush the log at every + commit, but only once per second */ } else if (srv_win_file_flush_method == - SRV_WIN_IO_UNBUFFERED) { - attributes = attributes | FILE_FLAG_NO_BUFFERING; + SRV_WIN_IO_UNBUFFERED) { + attributes = attributes | FILE_FLAG_NO_BUFFERING; } #endif } else { @@ -1207,7 +1187,7 @@ try_again: file = CreateFile((LPCTSTR) name, GENERIC_READ | GENERIC_WRITE, /* read and write access */ - share_mode, /* File can be read also by other + share_mode, /* File can be read also by other processes; we must give the read permission because of ibbackup. We do not give the write permission to @@ -1244,8 +1224,8 @@ try_again: const char* mode_str = NULL; const char* type_str = NULL; const char* purpose_str = NULL; - -try_again: + +try_again: ut_a(name); if (create_mode == OS_FILE_OPEN || create_mode == OS_FILE_OPEN_RAW @@ -1268,47 +1248,47 @@ try_again: } else if (type == OS_DATA_FILE) { type_str = "DATA"; } else { - ut_error; + ut_error; } - + if (purpose == OS_FILE_AIO) { purpose_str = "AIO"; } else if (purpose == OS_FILE_NORMAL) { purpose_str = "NORMAL"; } else { - ut_error; + ut_error; } /* fprintf(stderr, "Opening file %s, mode %s, type %s, purpose %s\n", - name, mode_str, type_str, purpose_str); */ + name, mode_str, type_str, purpose_str); */ #ifdef O_SYNC - /* We let O_SYNC only affect log files; note that we map O_DSYNC to + /* We let O_SYNC only affect log files; note that we map O_DSYNC to O_SYNC because the datasync options seemed to corrupt files in 2001 in both Linux and Solaris */ if (type == OS_LOG_FILE - && srv_unix_file_flush_method == SRV_UNIX_O_DSYNC) { + && srv_unix_file_flush_method == SRV_UNIX_O_DSYNC) { /* fprintf(stderr, "Using O_SYNC for file %s\n", name); */ - create_flag = create_flag | O_SYNC; + create_flag = create_flag | O_SYNC; } #endif #ifdef O_DIRECT - /* We let O_DIRECT only affect data files */ + /* We let O_DIRECT only affect data files */ if (type != OS_LOG_FILE - && srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) { + && srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) { /* fprintf(stderr, "Using O_DIRECT for file %s\n", name); */ - create_flag = create_flag | O_DIRECT; + create_flag = create_flag | O_DIRECT; } #endif if (create_mode == OS_FILE_CREATE) { - file = open(name, create_flag, os_innodb_umask); - } else { - file = open(name, create_flag); - } - + file = open(name, create_flag, os_innodb_umask); + } else { + file = open(name, create_flag); + } + if (file == -1) { *success = FALSE; @@ -1345,7 +1325,7 @@ try_again: *success = TRUE; } - return(file); + return(file); #endif /* __WIN__ */ } @@ -1383,7 +1363,7 @@ loop: fprintf(stderr, "InnoDB: Warning: cannot delete file %s\n" "InnoDB: Are you running ibbackup to back up the file?\n", name); - + os_file_get_last_error(TRUE); /* print error information */ } @@ -1445,7 +1425,7 @@ loop: fprintf(stderr, "InnoDB: Warning: cannot delete file %s\n" "InnoDB: Are you running ibbackup to back up the file?\n", name); - + os_file_get_last_error(TRUE); /* print error information */ } @@ -1620,16 +1600,16 @@ os_file_get_size( return(FALSE); } - + if (sizeof(off_t) > 4) { - *size = (ulint)(offs & 0xFFFFFFFFUL); + *size = (ulint)(offs & 0xFFFFFFFFUL); *size_high = (ulint)(offs >> 32); } else { *size = (ulint) offs; *size_high = 0; } - - return(TRUE); + + return(TRUE); #endif } @@ -1673,8 +1653,8 @@ os_file_set_size( ib_longlong current_size; ib_longlong desired_size; ibool ret; - byte* buf; - byte* buf2; + byte* buf; + byte* buf2; ulint buf_size; ut_a(size == (size & 0xFFFFFFFF)); @@ -1694,7 +1674,7 @@ os_file_set_size( memset(buf, 0, buf_size); if (desired_size >= (ib_longlong)(100 * 1024 * 1024)) { - + fprintf(stderr, "InnoDB: Progress in MB:"); } @@ -1707,29 +1687,29 @@ os_file_set_size( n_bytes = buf_size; } - ret = os_file_write(name, file, buf, - (ulint)(current_size & 0xFFFFFFFF), - (ulint)(current_size >> 32), - n_bytes); - if (!ret) { + ret = os_file_write(name, file, buf, + (ulint)(current_size & 0xFFFFFFFF), + (ulint)(current_size >> 32), + n_bytes); + if (!ret) { ut_free(buf2); - goto error_handling; - } - + goto error_handling; + } + /* Print about progress for each 100 MB written */ if ((current_size + n_bytes) / (ib_longlong)(100 * 1024 * 1024) - != current_size / (ib_longlong)(100 * 1024 * 1024)) { + != current_size / (ib_longlong)(100 * 1024 * 1024)) { - fprintf(stderr, " %lu00", + fprintf(stderr, " %lu00", (ulong) ((current_size + n_bytes) / (ib_longlong)(100 * 1024 * 1024))); } - - current_size += n_bytes; + + current_size += n_bytes; } if (desired_size >= (ib_longlong)(100 * 1024 * 1024)) { - + fprintf(stderr, "\n"); } @@ -1738,7 +1718,7 @@ os_file_set_size( ret = os_file_flush(file); if (ret) { - return(TRUE); + return(TRUE); } error_handling: @@ -1790,7 +1770,7 @@ os_file_flush( if (srv_start_raw_disk_in_use && GetLastError() == ERROR_INVALID_FUNCTION) { - return(TRUE); + return(TRUE); } os_file_handle_error(NULL, "flush"); @@ -1817,7 +1797,7 @@ os_file_flush( if (!srv_have_fullfsync) { /* If we are not on an operating system that supports this, - then fall back to a plain fsync. */ + then fall back to a plain fsync. */ ret = fsync(file); } else { @@ -1825,7 +1805,7 @@ os_file_flush( if (ret) { /* If we are not on a file system that supports this, - then fall back to a plain fsync. */ + then fall back to a plain fsync. */ ret = fsync(file); } } @@ -1840,17 +1820,17 @@ os_file_flush( if (ret == 0) { return(TRUE); } - + /* Since Linux returns EINVAL if the 'file' is actually a raw device, we choose to ignore that error if we are using raw disks */ if (srv_start_raw_disk_in_use && errno == EINVAL) { - return(TRUE); + return(TRUE); } ut_print_timestamp(stderr); - + fprintf(stderr, " InnoDB: Error: the OS said file flush did not succeed\n"); @@ -1874,44 +1854,46 @@ os_file_pread( /* out: number of bytes read, -1 if error */ os_file_t file, /* in: handle to a file */ void* buf, /* in: buffer where to read */ - ulint n, /* in: number of bytes to read */ + ulint n, /* in: number of bytes to read */ ulint offset, /* in: least significant 32 bits of file offset from where to read */ ulint offset_high) /* in: most significant 32 bits of offset */ { - off_t offs; + off_t offs; ssize_t n_bytes; ut_a((offset & 0xFFFFFFFFUL) == offset); - - /* If off_t is > 4 bytes in size, then we assume we can pass a + + /* If off_t is > 4 bytes in size, then we assume we can pass a 64-bit address */ - if (sizeof(off_t) > 4) { - offs = (off_t)offset + (((off_t)offset_high) << 32); - - } else { - offs = (off_t)offset; + if (sizeof(off_t) > 4) { + offs = (off_t)offset + (((off_t)offset_high) << 32); + + } else { + offs = (off_t)offset; - if (offset_high > 0) { - fprintf(stderr, + if (offset_high > 0) { + fprintf(stderr, "InnoDB: Error: file read at offset > 4 GB\n"); } - } + } os_n_file_reads++; #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD) - os_mutex_enter(os_file_count_mutex); + os_mutex_enter(os_file_count_mutex); os_file_n_pending_preads++; - os_mutex_exit(os_file_count_mutex); + os_n_pending_reads++; + os_mutex_exit(os_file_count_mutex); - n_bytes = pread(file, buf, (ssize_t)n, offs); + n_bytes = pread(file, buf, (ssize_t)n, offs); - os_mutex_enter(os_file_count_mutex); + os_mutex_enter(os_file_count_mutex); os_file_n_pending_preads--; - os_mutex_exit(os_file_count_mutex); + os_n_pending_reads--; + os_mutex_exit(os_file_count_mutex); return(n_bytes); #else @@ -1920,23 +1902,29 @@ os_file_pread( ssize_t ret; ulint i; + os_mutex_enter(os_file_count_mutex); + os_n_pending_reads++; + os_mutex_exit(os_file_count_mutex); + /* Protect the seek / read operation with a mutex */ i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; - + os_mutex_enter(os_file_seek_mutexes[i]); ret_offset = lseek(file, offs, SEEK_SET); if (ret_offset < 0) { - os_mutex_exit(os_file_seek_mutexes[i]); - - return(-1); + ret = -1; + } else { + ret = read(file, buf, (ssize_t)n); } - - ret = read(file, buf, (ssize_t)n); os_mutex_exit(os_file_seek_mutexes[i]); + os_mutex_enter(os_file_count_mutex); + os_n_pending_reads--; + os_mutex_exit(os_file_count_mutex); + return(ret); } #endif @@ -1951,93 +1939,104 @@ os_file_pwrite( /* out: number of bytes written, -1 if error */ os_file_t file, /* in: handle to a file */ const void* buf, /* in: buffer from where to write */ - ulint n, /* in: number of bytes to write */ + ulint n, /* in: number of bytes to write */ ulint offset, /* in: least significant 32 bits of file offset where to write */ ulint offset_high) /* in: most significant 32 bits of offset */ { ssize_t ret; - off_t offs; + off_t offs; ut_a((offset & 0xFFFFFFFFUL) == offset); - /* If off_t is > 4 bytes in size, then we assume we can pass a + /* If off_t is > 4 bytes in size, then we assume we can pass a 64-bit address */ - if (sizeof(off_t) > 4) { - offs = (off_t)offset + (((off_t)offset_high) << 32); - } else { - offs = (off_t)offset; + if (sizeof(off_t) > 4) { + offs = (off_t)offset + (((off_t)offset_high) << 32); + } else { + offs = (off_t)offset; - if (offset_high > 0) { - fprintf(stderr, + if (offset_high > 0) { + fprintf(stderr, "InnoDB: Error: file write at offset > 4 GB\n"); } - } + } os_n_file_writes++; #if defined(HAVE_PWRITE) && !defined(HAVE_BROKEN_PREAD) - os_mutex_enter(os_file_count_mutex); + os_mutex_enter(os_file_count_mutex); os_file_n_pending_pwrites++; - os_mutex_exit(os_file_count_mutex); + os_n_pending_writes++; + os_mutex_exit(os_file_count_mutex); ret = pwrite(file, buf, (ssize_t)n, offs); - os_mutex_enter(os_file_count_mutex); + os_mutex_enter(os_file_count_mutex); os_file_n_pending_pwrites--; - os_mutex_exit(os_file_count_mutex); + os_n_pending_writes--; + os_mutex_exit(os_file_count_mutex); # ifdef UNIV_DO_FLUSH if (srv_unix_file_flush_method != SRV_UNIX_LITTLESYNC - && srv_unix_file_flush_method != SRV_UNIX_NOSYNC - && !os_do_not_call_flush_at_each_write) { - - /* Always do fsync to reduce the probability that when - the OS crashes, a database page is only partially - physically written to disk. */ + && srv_unix_file_flush_method != SRV_UNIX_NOSYNC + && !os_do_not_call_flush_at_each_write) { - ut_a(TRUE == os_file_flush(file)); + /* Always do fsync to reduce the probability that when + the OS crashes, a database page is only partially + physically written to disk. */ + + ut_a(TRUE == os_file_flush(file)); } # endif /* UNIV_DO_FLUSH */ - return(ret); + return(ret); #else { off_t ret_offset; ulint i; + os_mutex_enter(os_file_count_mutex); + os_n_pending_writes++; + os_mutex_exit(os_file_count_mutex); + /* Protect the seek / write operation with a mutex */ i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; - + os_mutex_enter(os_file_seek_mutexes[i]); ret_offset = lseek(file, offs, SEEK_SET); if (ret_offset < 0) { - os_mutex_exit(os_file_seek_mutexes[i]); + ret = -1; - return(-1); + goto func_exit; } - + ret = write(file, buf, (ssize_t)n); # ifdef UNIV_DO_FLUSH if (srv_unix_file_flush_method != SRV_UNIX_LITTLESYNC - && srv_unix_file_flush_method != SRV_UNIX_NOSYNC - && !os_do_not_call_flush_at_each_write) { + && srv_unix_file_flush_method != SRV_UNIX_NOSYNC + && !os_do_not_call_flush_at_each_write) { - /* Always do fsync to reduce the probability that when - the OS crashes, a database page is only partially - physically written to disk. */ + /* Always do fsync to reduce the probability that when + the OS crashes, a database page is only partially + physically written to disk. */ - ut_a(TRUE == os_file_flush(file)); + ut_a(TRUE == os_file_flush(file)); } # endif /* UNIV_DO_FLUSH */ +func_exit: os_mutex_exit(os_file_seek_mutexes[i]); + os_mutex_enter(os_file_count_mutex); + os_n_pending_writes--; + os_mutex_exit(os_file_count_mutex); + return(ret); } #endif @@ -2058,7 +2057,7 @@ os_file_read( offset where to read */ ulint offset_high, /* in: most significant 32 bits of offset */ - ulint n) /* in: number of bytes to read */ + ulint n) /* in: number of bytes to read */ { #ifdef __WIN__ BOOL ret; @@ -2068,13 +2067,13 @@ os_file_read( DWORD high; ibool retry; ulint i; - + ut_a((offset & 0xFFFFFFFFUL) == offset); os_n_file_reads++; os_bytes_read_since_printout += n; -try_again: +try_again: ut_ad(file); ut_ad(buf); ut_ad(n > 0); @@ -2082,9 +2081,13 @@ try_again: low = (DWORD) offset; high = (DWORD) offset_high; + os_mutex_enter(os_file_count_mutex); + os_n_pending_reads++; + os_mutex_exit(os_file_count_mutex); + /* Protect the seek / read operation with a mutex */ i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; - + os_mutex_enter(os_file_seek_mutexes[i]); ret2 = SetFilePointer(file, low, &high, FILE_BEGIN); @@ -2093,20 +2096,24 @@ try_again: os_mutex_exit(os_file_seek_mutexes[i]); + os_mutex_enter(os_file_count_mutex); + os_n_pending_reads--; + os_mutex_exit(os_file_count_mutex); + goto error_handling; - } - - os_n_pending_reads++; - - ret = ReadFile(file, buf, (DWORD) n, &len, NULL); + } - os_n_pending_reads--; + ret = ReadFile(file, buf, (DWORD) n, &len, NULL); os_mutex_exit(os_file_seek_mutexes[i]); - + + os_mutex_enter(os_file_count_mutex); + os_n_pending_reads--; + os_mutex_exit(os_file_count_mutex); + if (ret && len == n) { return(TRUE); - } + } #else ibool retry; ssize_t ret; @@ -2114,12 +2121,8 @@ try_again: os_bytes_read_since_printout += n; try_again: - os_n_pending_reads++; - ret = os_file_pread(file, buf, n, offset, offset_high); - os_n_pending_reads--; - if ((ulint)ret == n) { return(TRUE); @@ -2129,16 +2132,16 @@ try_again: "InnoDB: Error: tried to read %lu bytes at offset %lu %lu.\n" "InnoDB: Was only able to read %ld.\n", (ulong)n, (ulong)offset_high, (ulong)offset, (long)ret); -#endif +#endif #ifdef __WIN__ error_handling: #endif - retry = os_file_handle_error(NULL, "read"); + retry = os_file_handle_error(NULL, "read"); if (retry) { goto try_again; } - + fprintf(stderr, "InnoDB: Fatal error: cannot read from file. OS error number %lu.\n", #ifdef __WIN__ @@ -2169,7 +2172,7 @@ os_file_read_no_error_handling( offset where to read */ ulint offset_high, /* in: most significant 32 bits of offset */ - ulint n) /* in: number of bytes to read */ + ulint n) /* in: number of bytes to read */ { #ifdef __WIN__ BOOL ret; @@ -2179,13 +2182,13 @@ os_file_read_no_error_handling( DWORD high; ibool retry; ulint i; - + ut_a((offset & 0xFFFFFFFFUL) == offset); os_n_file_reads++; os_bytes_read_since_printout += n; -try_again: +try_again: ut_ad(file); ut_ad(buf); ut_ad(n > 0); @@ -2193,9 +2196,13 @@ try_again: low = (DWORD) offset; high = (DWORD) offset_high; + os_mutex_enter(os_file_count_mutex); + os_n_pending_reads++; + os_mutex_exit(os_file_count_mutex); + /* Protect the seek / read operation with a mutex */ i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; - + os_mutex_enter(os_file_seek_mutexes[i]); ret2 = SetFilePointer(file, low, &high, FILE_BEGIN); @@ -2204,20 +2211,24 @@ try_again: os_mutex_exit(os_file_seek_mutexes[i]); + os_mutex_enter(os_file_count_mutex); + os_n_pending_reads--; + os_mutex_exit(os_file_count_mutex); + goto error_handling; - } - - os_n_pending_reads++; - + } + ret = ReadFile(file, buf, (DWORD) n, &len, NULL); - os_n_pending_reads--; - os_mutex_exit(os_file_seek_mutexes[i]); - + + os_mutex_enter(os_file_count_mutex); + os_n_pending_reads--; + os_mutex_exit(os_file_count_mutex); + if (ret && len == n) { return(TRUE); - } + } #else ibool retry; ssize_t ret; @@ -2225,26 +2236,22 @@ try_again: os_bytes_read_since_printout += n; try_again: - os_n_pending_reads++; - ret = os_file_pread(file, buf, n, offset, offset_high); - os_n_pending_reads--; - if ((ulint)ret == n) { return(TRUE); } -#endif +#endif #ifdef __WIN__ error_handling: #endif - retry = os_file_handle_error_no_exit(NULL, "read"); + retry = os_file_handle_error_no_exit(NULL, "read"); if (retry) { goto try_again; } - + return(FALSE); } @@ -2265,7 +2272,7 @@ os_file_read_string( if (size == 0) { return; } - + rewind(file); flen = fread(str, 1, size - 1, file); str[flen] = '\0'; @@ -2287,7 +2294,7 @@ os_file_write( offset where to write */ ulint offset_high, /* in: most significant 32 bits of offset */ - ulint n) /* in: number of bytes to write */ + ulint n) /* in: number of bytes to write */ { #ifdef __WIN__ BOOL ret; @@ -2309,10 +2316,14 @@ os_file_write( retry: low = (DWORD) offset; high = (DWORD) offset_high; - + + os_mutex_enter(os_file_count_mutex); + os_n_pending_writes++; + os_mutex_exit(os_file_count_mutex); + /* Protect the seek / write operation with a mutex */ i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; - + os_mutex_enter(os_file_seek_mutexes[i]); ret2 = SetFilePointer(file, low, &high, FILE_BEGIN); @@ -2320,7 +2331,11 @@ retry: if (ret2 == 0xFFFFFFFF && GetLastError() != NO_ERROR) { os_mutex_exit(os_file_seek_mutexes[i]); - + + os_mutex_enter(os_file_count_mutex); + os_n_pending_writes--; + os_mutex_exit(os_file_count_mutex); + ut_print_timestamp(stderr); fprintf(stderr, @@ -2333,14 +2348,10 @@ retry: (ulong) GetLastError()); return(FALSE); - } + } - os_n_pending_writes++; - ret = WriteFile(file, buf, (DWORD) n, &len, NULL); - os_n_pending_writes--; - /* Always do fsync to reduce the probability that when the OS crashes, a database page is only partially physically written to disk. */ @@ -2352,6 +2363,10 @@ retry: os_mutex_exit(os_file_seek_mutexes[i]); + os_mutex_enter(os_file_count_mutex); + os_n_pending_writes--; + os_mutex_exit(os_file_count_mutex); + if (ret && len == n) { return(TRUE); @@ -2360,18 +2375,18 @@ retry: /* If some background file system backup tool is running, then, at least in Windows 2000, we may get here a specific error. Let us retry the operation 100 times, with 1 second waits. */ - + if (GetLastError() == ERROR_LOCK_VIOLATION && n_retries < 100) { os_thread_sleep(1000000); - + n_retries++; goto retry; - } - + } + if (!os_has_said_disk_full) { - + err = (ulint)GetLastError(); ut_print_timestamp(stderr); @@ -2401,20 +2416,16 @@ retry: return(FALSE); #else ssize_t ret; - - os_n_pending_writes++; - + ret = os_file_pwrite(file, buf, n, offset, offset_high); - os_n_pending_writes--; - if ((ulint)ret == n) { return(TRUE); } if (!os_has_said_disk_full) { - + ut_print_timestamp(stderr); fprintf(stderr, @@ -2438,7 +2449,7 @@ retry: os_has_said_disk_full = TRUE; } - return(FALSE); + return(FALSE); #endif } @@ -2449,14 +2460,14 @@ ibool os_file_status( /*===========*/ /* out: TRUE if call succeeded */ - const char* path, /* in: pathname of the file */ + const char* path, /* in: pathname of the file */ ibool* exists, /* out: TRUE if file exists */ os_file_type_t* type) /* out: type of the file (if it exists) */ { #ifdef __WIN__ int ret; struct _stat statinfo; - + ret = _stat(path, &statinfo); if (ret && (errno == ENOENT || errno == ENOTDIR)) { /* file does not exist */ @@ -2464,27 +2475,27 @@ os_file_status( return(TRUE); } else if (ret) { /* file exists, but stat call failed */ - + os_file_handle_error_no_exit(path, "stat"); - + return(FALSE); } - + if (_S_IFDIR & statinfo.st_mode) { *type = OS_FILE_TYPE_DIR; } else if (_S_IFREG & statinfo.st_mode) { - *type = OS_FILE_TYPE_FILE; + *type = OS_FILE_TYPE_FILE; } else { - *type = OS_FILE_TYPE_UNKNOWN; + *type = OS_FILE_TYPE_UNKNOWN; } *exists = TRUE; - + return(TRUE); #else int ret; struct stat statinfo; - + ret = stat(path, &statinfo); if (ret && (errno == ENOENT || errno == ENOTDIR)) { /* file does not exist */ @@ -2492,24 +2503,24 @@ os_file_status( return(TRUE); } else if (ret) { /* file exists, but stat call failed */ - + os_file_handle_error_no_exit(path, "stat"); - + return(FALSE); } - + if (S_ISDIR(statinfo.st_mode)) { *type = OS_FILE_TYPE_DIR; } else if (S_ISLNK(statinfo.st_mode)) { - *type = OS_FILE_TYPE_LINK; + *type = OS_FILE_TYPE_LINK; } else if (S_ISREG(statinfo.st_mode)) { - *type = OS_FILE_TYPE_FILE; + *type = OS_FILE_TYPE_FILE; } else { - *type = OS_FILE_TYPE_UNKNOWN; + *type = OS_FILE_TYPE_UNKNOWN; } *exists = TRUE; - + return(TRUE); #endif } @@ -2519,15 +2530,15 @@ This function returns information about the specified file */ ibool os_file_get_status( -/*===========*/ +/*===============*/ /* out: TRUE if stat information found */ - const char* path, /* in: pathname of the file */ + const char* path, /* in: pathname of the file */ os_file_stat_t* stat_info) /* information of a file in a directory */ { #ifdef __WIN__ int ret; struct _stat statinfo; - + ret = _stat(path, &statinfo); if (ret && (errno == ENOENT || errno == ENOTDIR)) { /* file does not exist */ @@ -2535,29 +2546,29 @@ os_file_get_status( return(FALSE); } else if (ret) { /* file exists, but stat call failed */ - + os_file_handle_error_no_exit(path, "stat"); - + return(FALSE); } if (_S_IFDIR & statinfo.st_mode) { stat_info->type = OS_FILE_TYPE_DIR; } else if (_S_IFREG & statinfo.st_mode) { - stat_info->type = OS_FILE_TYPE_FILE; + stat_info->type = OS_FILE_TYPE_FILE; } else { - stat_info->type = OS_FILE_TYPE_UNKNOWN; + stat_info->type = OS_FILE_TYPE_UNKNOWN; } stat_info->ctime = statinfo.st_ctime; stat_info->atime = statinfo.st_atime; stat_info->mtime = statinfo.st_mtime; - stat_info->size = statinfo.st_size; - + stat_info->size = statinfo.st_size; + return(TRUE); #else int ret; struct stat statinfo; - + ret = stat(path, &statinfo); if (ret && (errno == ENOENT || errno == ENOTDIR)) { @@ -2566,27 +2577,27 @@ os_file_get_status( return(FALSE); } else if (ret) { /* file exists, but stat call failed */ - + os_file_handle_error_no_exit(path, "stat"); - + return(FALSE); } - + if (S_ISDIR(statinfo.st_mode)) { stat_info->type = OS_FILE_TYPE_DIR; } else if (S_ISLNK(statinfo.st_mode)) { - stat_info->type = OS_FILE_TYPE_LINK; + stat_info->type = OS_FILE_TYPE_LINK; } else if (S_ISREG(statinfo.st_mode)) { - stat_info->type = OS_FILE_TYPE_FILE; + stat_info->type = OS_FILE_TYPE_FILE; } else { - stat_info->type = OS_FILE_TYPE_UNKNOWN; + stat_info->type = OS_FILE_TYPE_UNKNOWN; } stat_info->ctime = statinfo.st_ctime; stat_info->atime = statinfo.st_atime; stat_info->mtime = statinfo.st_mtime; - stat_info->size = statinfo.st_size; - + stat_info->size = statinfo.st_size; + return(TRUE); #endif } @@ -2612,18 +2623,18 @@ yields a complete pathname. The return value is a copy of the directory component of the pathname. The copy is allocated from heap. It is the caller responsibility -to free it after it is no longer needed. +to free it after it is no longer needed. The following list of examples (taken from SUSv2) shows the strings returned by dirname and basename for different paths: - path dirname basename - "/usr/lib" "/usr" "lib" - "/usr/" "/" "usr" - "usr" "." "usr" - "/" "/" "/" - "." "." "." - ".." "." ".." + path dirname basename + "/usr/lib" "/usr" "lib" + "/usr/" "/" "usr" + "usr" "." "usr" + "/" "/" "/" + "." "." "." + ".." "." ".." */ char* @@ -2653,10 +2664,10 @@ os_file_dirname( return(mem_strdupl(path, last_slash - path)); } - + /******************************************************************** Creates all missing subdirectories along the given path. */ - + ibool os_file_create_subdirs_if_needed( /*=============================*/ @@ -2665,12 +2676,12 @@ os_file_create_subdirs_if_needed( const char* path) /* in: path name */ { char* subdir; - ibool success, subdir_exists; + ibool success, subdir_exists; os_file_type_t type; subdir = os_file_dirname(path); if (strlen(subdir) == 1 - && (*subdir == OS_FILE_PATH_SEPARATOR || *subdir == '.')) { + && (*subdir == OS_FILE_PATH_SEPARATOR || *subdir == '.')) { /* subdir is root or cwd, nothing to do */ mem_free(subdir); @@ -2719,32 +2730,32 @@ os_aio_array_create( /* out, own: aio array */ ulint n, /* in: maximum number of pending aio operations allowed; n must be divisible by n_segments */ - ulint n_segments) /* in: number of segments in the aio array */ + ulint n_segments) /* in: number of segments in the aio array */ { os_aio_array_t* array; ulint i; os_aio_slot_t* slot; #ifdef WIN_ASYNC_IO OVERLAPPED* over; -#endif +#endif ut_a(n > 0); ut_a(n_segments > 0); array = ut_malloc(sizeof(os_aio_array_t)); - array->mutex = os_mutex_create(NULL); + array->mutex = os_mutex_create(NULL); array->not_full = os_event_create(NULL); array->is_empty = os_event_create(NULL); os_event_set(array->is_empty); - - array->n_slots = n; + + array->n_slots = n; array->n_segments = n_segments; array->n_reserved = 0; array->slots = ut_malloc(n * sizeof(os_aio_slot_t)); #ifdef __WIN__ array->native_events = ut_malloc(n * sizeof(os_native_event_t)); -#endif +#endif for (i = 0; i < n; i++) { slot = os_aio_array_get_nth_slot(array, i); @@ -2760,7 +2771,7 @@ os_aio_array_create( *((array->native_events) + i) = over->hEvent; #endif } - + return(array); } @@ -2796,13 +2807,13 @@ os_aio_init( os_io_init_simple(); for (i = 0; i < n_segments; i++) { - srv_set_io_thread_op_info(i, "not started yet"); + srv_set_io_thread_op_info(i, "not started yet"); } n_per_seg = n / n_segments; n_write_segs = (n_segments - 2) / 2; n_read_segs = n_segments - 2 - n_write_segs; - + /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */ os_aio_ibuf_array = os_aio_array_create(n_per_seg, 1); @@ -2817,14 +2828,14 @@ os_aio_init( n_read_segs); for (i = 2; i < 2 + n_read_segs; i++) { ut_a(i < SRV_MAX_N_IO_THREADS); - srv_io_thread_function[i] = "read thread"; + srv_io_thread_function[i] = "read thread"; } os_aio_write_array = os_aio_array_create(n_write_segs * n_per_seg, n_write_segs); for (i = 2 + n_read_segs; i < n_segments; i++) { ut_a(i < SRV_MAX_N_IO_THREADS); - srv_io_thread_function[i] = "write thread"; + srv_io_thread_function[i] = "write thread"; } os_aio_sync_array = os_aio_array_create(n_slots_sync, 1); @@ -2846,10 +2857,10 @@ os_aio_init( for this to work, the current thread must be the first created in the database, so that all its children will inherit its signal mask */ - + /* TODO: to work MySQL needs the SIGALARM signal; the following will not work yet! */ - sigemptyset(&sigset); + sigemptyset(&sigset); sigaddset(&sigset, SIGRTMIN + 1 + 0); sigaddset(&sigset, SIGRTMIN + 1 + 1); sigaddset(&sigset, SIGRTMIN + 1 + 2); @@ -2873,7 +2884,7 @@ os_aio_array_wake_win_aio_at_shutdown( for (i = 0; i < array->n_slots; i++) { - os_event_set((array->slots + i)->event); + os_event_set((array->slots + i)->event); } } #endif @@ -2889,7 +2900,7 @@ os_aio_wake_all_threads_at_shutdown(void) ulint i; #ifdef WIN_ASYNC_IO - /* This code wakes up all ai/o threads in Windows native aio */ + /* This code wakes up all ai/o threads in Windows native aio */ os_aio_array_wake_win_aio_at_shutdown(os_aio_read_array); os_aio_array_wake_win_aio_at_shutdown(os_aio_write_array); os_aio_array_wake_win_aio_at_shutdown(os_aio_ibuf_array); @@ -2898,11 +2909,11 @@ os_aio_wake_all_threads_at_shutdown(void) /* This loop wakes up all simulated ai/o threads */ for (i = 0; i < os_aio_n_segments; i++) { - + os_event_set(os_aio_segment_wait_events[i]); - } + } } - + /**************************************************************************** Waits until there are no pending writes in os_aio_write_array. There can be other, synchronous, pending writes. */ @@ -2933,7 +2944,7 @@ os_aio_get_segment_no_from_slot( } else if (array == os_aio_log_array) { segment = 1; - + } else if (array == os_aio_read_array) { seg_len = os_aio_read_array->n_slots / os_aio_read_array->n_segments; @@ -2964,7 +2975,7 @@ os_aio_get_array_and_local_segment( { ulint segment; - ut_a(global_segment < os_aio_n_segments); + ut_a(global_segment < os_aio_n_segments); if (global_segment == 0) { *array = os_aio_ibuf_array; @@ -2973,7 +2984,7 @@ os_aio_get_array_and_local_segment( } else if (global_segment == 1) { *array = os_aio_log_array; segment = 0; - + } else if (global_segment < os_aio_read_array->n_segments + 2) { *array = os_aio_read_array; @@ -2997,9 +3008,9 @@ ulint os_aio_get_array_no( /*================*/ os_aio_array_t* array) /* in: aio array */ -{ +{ if (array == os_aio_ibuf_array) { - + return(0); } else if (array == os_aio_log_array) { @@ -3027,7 +3038,7 @@ os_aio_get_array_from_no( /*=====================*/ /* out: aio array */ ulint n) /* in: array number */ -{ +{ if (n == 0) { return(os_aio_ibuf_array); } else if (n == 1) { @@ -3093,7 +3104,7 @@ loop: os_aio_simulated_wake_handler_threads(); } - + os_event_wait(array->not_full); goto loop; @@ -3116,7 +3127,7 @@ loop: if (array->n_reserved == array->n_slots) { os_event_reset(array->not_full); } - + slot->reserved = TRUE; slot->reservation_time = time(NULL); slot->message1 = message1; @@ -3129,8 +3140,8 @@ loop: slot->offset = offset; slot->offset_high = offset_high; slot->io_already_done = FALSE; - -#ifdef WIN_ASYNC_IO + +#ifdef WIN_ASYNC_IO control = &(slot->control); control->Offset = (DWORD)offset; control->OffsetHigh = (DWORD)offset_high; @@ -3142,7 +3153,7 @@ loop: offset = offset + (offset_high << 32); #else ut_a(offset_high == 0); -#endif +#endif control = &(slot->control); control->aio_fildes = file; control->aio_buf = buf; @@ -3179,7 +3190,7 @@ os_aio_array_free_slot( os_mutex_enter(array->mutex); ut_ad(slot->reserved); - + slot->reserved = FALSE; array->n_reserved--; @@ -3192,7 +3203,7 @@ os_aio_array_free_slot( os_event_set(array->is_empty); } -#ifdef WIN_ASYNC_IO +#ifdef WIN_ASYNC_IO os_event_reset(slot->event); #endif os_mutex_exit(array->mutex); @@ -3228,7 +3239,7 @@ os_aio_simulated_wake_handler_thread( if (slot->reserved) { /* Found an i/o request */ - + break; } } @@ -3253,7 +3264,7 @@ os_aio_simulated_wake_handler_threads(void) /* We do not use simulated aio: do nothing */ return; - } + } os_aio_recommend_sleep_for_read_threads = FALSE; @@ -3281,7 +3292,7 @@ os_aio_simulated_put_read_threads_to_sleep(void) os_aio_get_array_and_local_segment(&array, g); if (array == os_aio_read_array) { - + os_event_reset(os_aio_segment_wait_events[g]); } } @@ -3348,7 +3359,7 @@ os_aio( wake_later = mode & OS_AIO_SIMULATED_WAKE_LATER; mode = mode & (~OS_AIO_SIMULATED_WAKE_LATER); - + if (mode == OS_AIO_SYNC #ifdef WIN_ASYNC_IO && !os_aio_use_native_aio @@ -3395,7 +3406,7 @@ try_again: array = NULL; /* Eliminate compiler warning */ ut_error; } - + slot = os_aio_array_reserve_slot(type, array, message1, message2, file, name, buf, offset, offset_high, n); if (type == OS_FILE_READ) { @@ -3403,7 +3414,7 @@ try_again: #ifdef WIN_ASYNC_IO os_n_file_reads++; os_bytes_read_since_printout += len; - + ret = ReadFile(file, buf, (DWORD)n, &len, &(slot->control)); #elif defined(POSIX_ASYNC_IO) @@ -3441,21 +3452,22 @@ try_again: #ifdef WIN_ASYNC_IO if (os_aio_use_native_aio) { if ((ret && len == n) - || (!ret && GetLastError() == ERROR_IO_PENDING)) { + || (!ret && GetLastError() == ERROR_IO_PENDING)) { /* aio was queued successfully! */ - - if (mode == OS_AIO_SYNC) { - /* We want a synchronous i/o operation on a file - where we also use async i/o: in Windows we must - use the same wait mechanism as for async i/o */ - - retval = os_aio_windows_handle(ULINT_UNDEFINED, + + if (mode == OS_AIO_SYNC) { + /* We want a synchronous i/o operation on a + file where we also use async i/o: in Windows + we must use the same wait mechanism as for + async i/o */ + + retval = os_aio_windows_handle(ULINT_UNDEFINED, slot->pos, - &dummy_mess1, &dummy_mess2, + &dummy_mess1, &dummy_mess2, &dummy_type); - return(retval); - } + return(retval); + } return(TRUE); } @@ -3476,7 +3488,7 @@ try_again: if (retry) { goto try_again; - } + } return(FALSE); } @@ -3503,7 +3515,7 @@ os_aio_windows_handle( sync aio is used, and this parameter is ignored */ ulint pos, /* this parameter is used only in sync aio: - wait for the aio slot at this position */ + wait for the aio slot at this position */ fil_node_t**message1, /* out: the messages passed with the aio request; note that also in the case where the aio operation failed, these output @@ -3527,7 +3539,7 @@ os_aio_windows_handle( } else { segment = os_aio_get_array_and_local_segment(&array, segment); } - + /* NOTE! We only access constant fields in os_aio_array. Therefore we do not have to acquire the protecting mutex yet */ @@ -3569,19 +3581,19 @@ os_aio_windows_handle( # ifdef UNIV_DO_FLUSH if (slot->type == OS_FILE_WRITE && !os_do_not_call_flush_at_each_write) { - ut_a(TRUE == os_file_flush(slot->file)); + ut_a(TRUE == os_file_flush(slot->file)); } # endif /* UNIV_DO_FLUSH */ } else { os_file_handle_error(slot->name, "Windows aio"); - + ret_val = FALSE; - } + } os_mutex_exit(array->mutex); os_aio_array_free_slot(array, slot); - + return(ret_val); } #endif @@ -3608,13 +3620,13 @@ os_aio_posix_handle( os_aio_slot_t* slot; siginfo_t info; sigset_t sigset; - sigset_t proc_sigset; - sigset_t thr_sigset; + sigset_t proc_sigset; + sigset_t thr_sigset; int ret; - int i; - int sig; - - sigemptyset(&sigset); + int i; + int sig; + + sigemptyset(&sigset); sigaddset(&sigset, SIGRTMIN + 1 + array_no); pthread_sigmask(SIG_UNBLOCK, &sigset, NULL); @@ -3635,10 +3647,10 @@ os_aio_posix_handle( if (sig != SIGRTMIN + 1 + array_no) { ut_error; - + return(FALSE); } - + fputs("Handling POSIX aio\n", stderr); array = os_aio_get_array_from_no(array_no); @@ -3662,7 +3674,7 @@ os_aio_posix_handle( os_mutex_exit(array->mutex); os_aio_array_free_slot(array, slot); - + return(TRUE); } #endif @@ -3705,9 +3717,9 @@ os_aio_simulated_handle( ulint n; ulint i; ulint len2; - + segment = os_aio_get_array_and_local_segment(&array, global_segment); - + restart: /* NOTE! We only access constant fields in os_aio_array. Therefore we do not have to acquire the protecting mutex yet */ @@ -3722,14 +3734,14 @@ restart: /* Look through n slots after the segment * n'th slot */ if (array == os_aio_read_array - && os_aio_recommend_sleep_for_read_threads) { + && os_aio_recommend_sleep_for_read_threads) { /* Give other threads chance to add several i/os to the array at once. */ goto recommended_sleep; } - + os_mutex_enter(array->mutex); srv_set_io_thread_op_info(global_segment, @@ -3737,7 +3749,7 @@ restart: /* Check if there is a slot for which the i/o has already been done */ - + for (i = 0; i < n; i++) { slot = os_aio_array_get_nth_slot(array, i + segment * n); @@ -3749,7 +3761,7 @@ restart: } ret = TRUE; - + goto slot_io_done; } } @@ -3767,14 +3779,14 @@ restart: slot = os_aio_array_get_nth_slot(array, i + segment * n); if (slot->reserved) { - age = (ulint)difftime(time(NULL), + age = (ulint)difftime(time(NULL), slot->reservation_time); if ((age >= 2 && age > biggest_age) - || (age >= 2 && age == biggest_age - && slot->offset < lowest_offset)) { + || (age >= 2 && age == biggest_age + && slot->offset < lowest_offset)) { - /* Found an i/o request */ + /* Found an i/o request */ consecutive_ios[0] = slot; n_consecutive = 1; @@ -3786,19 +3798,19 @@ restart: } if (n_consecutive == 0) { - /* There were no old requests. Look for an i/o request at the + /* There were no old requests. Look for an i/o request at the lowest offset in the array (we ignore the high 32 bits of the offset in these heuristics) */ lowest_offset = ULINT_MAX; - + for (i = 0; i < n; i++) { - slot = os_aio_array_get_nth_slot(array, + slot = os_aio_array_get_nth_slot(array, i + segment * n); if (slot->reserved && slot->offset < lowest_offset) { - /* Found an i/o request */ + /* Found an i/o request */ consecutive_ios[0] = slot; n_consecutive = 1; @@ -3819,17 +3831,17 @@ restart: /* Check if there are several consecutive blocks to read or write */ -consecutive_loop: +consecutive_loop: for (i = 0; i < n; i++) { slot2 = os_aio_array_get_nth_slot(array, i + segment * n); if (slot2->reserved && slot2 != slot - && slot2->offset == slot->offset + slot->len - && slot->offset + slot->len > slot->offset /* check that - sum does not wrap over */ - && slot2->offset_high == slot->offset_high - && slot2->type == slot->type - && slot2->file == slot->file) { + && slot2->offset == slot->offset + slot->len + /* check that sum does not wrap over */ + && slot->offset + slot->len > slot->offset + && slot2->offset_high == slot->offset_high + && slot2->type == slot->type + && slot2->file == slot->file) { /* Found a consecutive i/o request */ @@ -3839,7 +3851,7 @@ consecutive_loop: slot = slot2; if (n_consecutive < OS_AIO_MERGE_N_CONSECUTIVE) { - + goto consecutive_loop; } else { break; @@ -3855,7 +3867,7 @@ consecutive_loop: total_len = 0; slot = consecutive_ios[0]; - + for (i = 0; i < n_consecutive; i++) { total_len += consecutive_ios[i]->len; } @@ -3871,7 +3883,7 @@ consecutive_loop: combined_buf = ut_align(combined_buf2, UNIV_PAGE_SIZE); } - + /* We release the array mutex for the time of the i/o: NOTE that this assumes that there is just one i/o-handler thread serving a single segment of slots! */ @@ -3881,7 +3893,7 @@ consecutive_loop: if (slot->type == OS_FILE_WRITE && n_consecutive > 1) { /* Copy the buffers to the combined buffer */ offs = 0; - + for (i = 0; i < n_consecutive; i++) { ut_memcpy(combined_buf + offs, consecutive_ios[i]->buf, @@ -3889,7 +3901,7 @@ consecutive_loop: offs += consecutive_ios[i]->len; } } - + srv_set_io_thread_op_info(global_segment, "doing file i/o"); if (os_aio_print_debug) { @@ -3903,7 +3915,7 @@ consecutive_loop: if (slot->type == OS_FILE_WRITE) { if (array == os_aio_write_array) { if ((total_len % UNIV_PAGE_SIZE != 0) - || (slot->offset % UNIV_PAGE_SIZE != 0)) { + || (slot->offset % UNIV_PAGE_SIZE != 0)) { fprintf(stderr, "InnoDB: Error: trying a displaced write to %s %lu %lu, len %lu\n", slot->name, (ulong) slot->offset_high, @@ -3911,7 +3923,7 @@ consecutive_loop: (ulong) total_len); ut_error; } - + /* Do a 'last millisecond' check that the page end is sensible; reported page checksum errors from Linux seem to wipe over the page end */ @@ -3920,22 +3932,22 @@ consecutive_loop: len2 += UNIV_PAGE_SIZE) { if (mach_read_from_4(combined_buf + len2 + FIL_PAGE_LSN + 4) - != mach_read_from_4(combined_buf + len2 - + UNIV_PAGE_SIZE - - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { - ut_print_timestamp(stderr); - fprintf(stderr, + != mach_read_from_4(combined_buf + len2 + + UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: ERROR: The page to be written seems corrupt!\n"); - fprintf(stderr, + fprintf(stderr, "InnoDB: Writing a block of %lu bytes, currently writing at offset %lu\n", (ulong)total_len, (ulong)len2); buf_page_print(combined_buf + len2); - fprintf(stderr, + fprintf(stderr, "InnoDB: ERROR: The page to be written seems corrupt!\n"); } } } - + ret = os_file_write(slot->name, slot->file, combined_buf, slot->offset, slot->offset_high, total_len); } else { @@ -3953,10 +3965,10 @@ consecutive_loop: if (slot->type == OS_FILE_READ && n_consecutive > 1) { /* Copy the combined buffer to individual buffers */ offs = 0; - + for (i = 0; i < n_consecutive; i++) { - ut_memcpy(consecutive_ios[i]->buf, combined_buf + offs, + ut_memcpy(consecutive_ios[i]->buf, combined_buf + offs, consecutive_ios[i]->len); offs += consecutive_ios[i]->len; } @@ -3977,7 +3989,7 @@ consecutive_loop: /* We return the messages for the first slot now, and if there were several slots, the messages will be returned with subsequent calls of this function */ - + slot_io_done: ut_a(slot->reserved); @@ -3990,7 +4002,7 @@ slot_io_done: os_mutex_exit(array->mutex); os_aio_array_free_slot(array, slot); - + return(ret); wait_for_io: @@ -3998,7 +4010,7 @@ wait_for_io: /* We wait here until there again can be i/os in the segment of this thread */ - + os_event_reset(os_aio_segment_wait_events[global_segment]); os_mutex_exit(array->mutex); @@ -4013,7 +4025,7 @@ recommended_sleep: "InnoDB: i/o handler thread for i/o segment %lu wakes up\n", (ulong) global_segment); } - + goto restart; } @@ -4029,17 +4041,17 @@ os_aio_array_validate( os_aio_slot_t* slot; ulint n_reserved = 0; ulint i; - + ut_a(array); os_mutex_enter(array->mutex); ut_a(array->n_slots > 0); ut_a(array->n_segments > 0); - + for (i = 0; i < array->n_slots; i++) { slot = os_aio_array_get_nth_slot(array, i); - + if (slot->reserved) { n_reserved++; ut_a(slot->len > 0); @@ -4092,11 +4104,11 @@ os_aio_print( srv_io_thread_function[i]); #ifndef __WIN__ - if (os_aio_segment_wait_events[i]->is_set) { + if (os_aio_segment_wait_events[i]->is_set) { fprintf(file, " ev set"); } #endif - + fprintf(file, "\n"); } @@ -4105,17 +4117,17 @@ os_aio_print( array = os_aio_read_array; loop: ut_a(array); - + os_mutex_enter(array->mutex); ut_a(array->n_slots > 0); ut_a(array->n_segments > 0); - + n_reserved = 0; for (i = 0; i < array->n_slots; i++) { slot = os_aio_array_get_nth_slot(array, i); - + if (slot->reserved) { n_reserved++; /* fprintf(stderr, "Reserved slot, messages %p %p\n", @@ -4127,12 +4139,12 @@ loop: ut_a(array->n_reserved == n_reserved); fprintf(file, " %lu", (ulong) n_reserved); - + os_mutex_exit(array->mutex); if (array == os_aio_read_array) { fputs(", aio writes:", file); - + array = os_aio_write_array; goto loop; @@ -4173,9 +4185,9 @@ loop: if (os_file_n_pending_preads != 0 || os_file_n_pending_pwrites != 0) { fprintf(file, - "%lu pending preads, %lu pending pwrites\n", - (ulong) os_file_n_pending_preads, - (ulong) os_file_n_pending_pwrites); + "%lu pending preads, %lu pending pwrites\n", + (ulong) os_file_n_pending_preads, + (ulong) os_file_n_pending_pwrites); } if (os_n_file_reads == os_n_file_reads_old) { @@ -4199,7 +4211,7 @@ loop: os_n_file_writes_old = os_n_file_writes; os_n_fsyncs_old = os_n_fsyncs; os_bytes_read_since_printout = 0; - + os_last_printout = current_time; } @@ -4214,7 +4226,7 @@ os_aio_refresh_stats(void) os_n_file_writes_old = os_n_file_writes; os_n_fsyncs_old = os_n_fsyncs; os_bytes_read_since_printout = 0; - + os_last_printout = time(NULL); } @@ -4230,45 +4242,45 @@ os_aio_all_slots_free(void) { os_aio_array_t* array; ulint n_res = 0; - + array = os_aio_read_array; os_mutex_enter(array->mutex); - n_res += array->n_reserved; - + n_res += array->n_reserved; + os_mutex_exit(array->mutex); array = os_aio_write_array; os_mutex_enter(array->mutex); - n_res += array->n_reserved; - + n_res += array->n_reserved; + os_mutex_exit(array->mutex); array = os_aio_ibuf_array; os_mutex_enter(array->mutex); - n_res += array->n_reserved; - + n_res += array->n_reserved; + os_mutex_exit(array->mutex); array = os_aio_log_array; os_mutex_enter(array->mutex); - n_res += array->n_reserved; - + n_res += array->n_reserved; + os_mutex_exit(array->mutex); array = os_aio_sync_array; os_mutex_enter(array->mutex); - n_res += array->n_reserved; - + n_res += array->n_reserved; + os_mutex_exit(array->mutex); if (n_res == 0) { diff --git a/storage/innobase/os/os0proc.c b/storage/innobase/os/os0proc.c index 24bb007e504..fc1b2d0d2dd 100644 --- a/storage/innobase/os/os0proc.c +++ b/storage/innobase/os/os0proc.c @@ -89,59 +89,58 @@ os_awe_enable_lock_pages_in_mem(void) return(TRUE); #elif defined(__WIN2000__) - struct { - DWORD Count; - LUID_AND_ATTRIBUTES Privilege[1]; - } Info; + struct { + DWORD Count; + LUID_AND_ATTRIBUTES Privilege[1]; + } Info; HANDLE hProcess; - HANDLE Token; - BOOL Result; + HANDLE Token; + BOOL Result; hProcess = GetCurrentProcess(); - /* Open the token of the current process */ + /* Open the token of the current process */ - Result = OpenProcessToken(hProcess, - TOKEN_ADJUST_PRIVILEGES, - &Token); - if (Result != TRUE) { - fprintf(stderr, + Result = OpenProcessToken(hProcess, + TOKEN_ADJUST_PRIVILEGES, &Token); + if (Result != TRUE) { + fprintf(stderr, "InnoDB: AWE: Cannot open process token, error %lu\n", (ulint)GetLastError()); - return(FALSE); - } + return(FALSE); + } - Info.Count = 1; + Info.Count = 1; - Info.Privilege[0].Attributes = SE_PRIVILEGE_ENABLED; + Info.Privilege[0].Attributes = SE_PRIVILEGE_ENABLED; - /* Get the local unique identifier (LUID) of the SE_LOCK_MEMORY + /* Get the local unique identifier (LUID) of the SE_LOCK_MEMORY privilege */ - Result = LookupPrivilegeValue(NULL, SE_LOCK_MEMORY_NAME, - &(Info.Privilege[0].Luid)); - if (Result != TRUE) { - fprintf(stderr, + Result = LookupPrivilegeValue(NULL, SE_LOCK_MEMORY_NAME, + &(Info.Privilege[0].Luid)); + if (Result != TRUE) { + fprintf(stderr, "InnoDB: AWE: Cannot get local privilege value for %s, error %lu.\n", SE_LOCK_MEMORY_NAME, (ulint)GetLastError()); - return(FALSE); - } + return(FALSE); + } - /* Try to adjust the privilege */ + /* Try to adjust the privilege */ - Result = AdjustTokenPrivileges(Token, FALSE, - (PTOKEN_PRIVILEGES)&Info, - 0, NULL, NULL); - /* Check the result */ + Result = AdjustTokenPrivileges(Token, FALSE, + (PTOKEN_PRIVILEGES)&Info, + 0, NULL, NULL); + /* Check the result */ - if (Result != TRUE) { - fprintf(stderr, + if (Result != TRUE) { + fprintf(stderr, "InnoDB: AWE: Cannot adjust process token privileges, error %u.\n", GetLastError()); - return(FALSE); - } else if (GetLastError() != ERROR_SUCCESS) { - fprintf(stderr, + return(FALSE); + } else if (GetLastError() != ERROR_SUCCESS) { + fprintf(stderr, "InnoDB: AWE: Cannot enable SE_LOCK_MEMORY privilege, error %lu.\n" "InnoDB: In Windows XP Home you cannot use AWE. In Windows 2000 and XP\n" "InnoDB: Professional you must go to the Control Panel, to\n" @@ -159,7 +158,7 @@ os_awe_enable_lock_pages_in_mem(void) #ifdef __WIN__ fprintf(stderr, "InnoDB: AWE: Error: to use AWE you must use a ...-nt MySQL executable.\n"); -#endif +#endif return(FALSE); #endif } @@ -193,14 +192,14 @@ os_awe_allocate_physical_mem( #elif defined(__WIN2000__) BOOL bResult; - os_awe_t NumberOfPages; /* Question: why does Windows - use the name ULONG_PTR for - a scalar integer type? Maybe - because we may also refer to - &NumberOfPages? */ - os_awe_t NumberOfPagesInitial; - SYSTEM_INFO sSysInfo; - int PFNArraySize; + os_awe_t NumberOfPages; /* Question: why does Windows + use the name ULONG_PTR for + a scalar integer type? Maybe + because we may also refer to + &NumberOfPages? */ + os_awe_t NumberOfPagesInitial; + SYSTEM_INFO sSysInfo; + int PFNArraySize; if (n_megabytes > 64 * 1024) { @@ -211,9 +210,9 @@ os_awe_allocate_physical_mem( return(FALSE); } - GetSystemInfo(&sSysInfo); /* fill the system information structure */ + GetSystemInfo(&sSysInfo); /* fill the system information structure */ - if ((ulint)OS_AWE_X86_PAGE_SIZE != (ulint)sSysInfo.dwPageSize) { + if ((ulint)OS_AWE_X86_PAGE_SIZE != (ulint)sSysInfo.dwPageSize) { fprintf(stderr, "InnoDB: AWE: Error: this computer has a page size of %lu.\n" "InnoDB: Should be 4096 bytes for InnoDB AWE support to work.\n", @@ -222,36 +221,36 @@ os_awe_allocate_physical_mem( return(FALSE); } - /* Calculate the number of pages of memory to request */ + /* Calculate the number of pages of memory to request */ - NumberOfPages = n_megabytes * ((1024 * 1024) / OS_AWE_X86_PAGE_SIZE); - - /* Calculate the size of page_info for allocated physical pages */ + NumberOfPages = n_megabytes * ((1024 * 1024) / OS_AWE_X86_PAGE_SIZE); - PFNArraySize = NumberOfPages * sizeof(os_awe_t); + /* Calculate the size of page_info for allocated physical pages */ - *page_info = (os_awe_t*)HeapAlloc(GetProcessHeap(), 0, PFNArraySize); + PFNArraySize = NumberOfPages * sizeof(os_awe_t); + + *page_info = (os_awe_t*)HeapAlloc(GetProcessHeap(), 0, PFNArraySize); if (*page_info == NULL) { - fprintf(stderr, + fprintf(stderr, "InnoDB: AWE: Failed to allocate page info array from process heap, error %lu\n", (ulint)GetLastError()); - return(FALSE); - } + return(FALSE); + } ut_total_allocated_memory += PFNArraySize; - /* Enable this process' privilege to lock pages to physical memory */ + /* Enable this process' privilege to lock pages to physical memory */ if (!os_awe_enable_lock_pages_in_mem()) { return(FALSE); } - /* Allocate the physical memory */ + /* Allocate the physical memory */ - NumberOfPagesInitial = NumberOfPages; + NumberOfPagesInitial = NumberOfPages; os_awe_page_info = *page_info; os_awe_n_pages = (ulint)NumberOfPages; @@ -259,19 +258,18 @@ os_awe_allocate_physical_mem( /* Compilation note: if the compiler complains the function is not defined, see the note at the start of this file */ - bResult = AllocateUserPhysicalPages(GetCurrentProcess(), - &NumberOfPages, - *page_info); - if (bResult != TRUE) { - fprintf(stderr, + bResult = AllocateUserPhysicalPages(GetCurrentProcess(), + &NumberOfPages, *page_info); + if (bResult != TRUE) { + fprintf(stderr, "InnoDB: AWE: Cannot allocate physical pages, error %lu.\n", (ulint)GetLastError()); - return(FALSE); - } + return(FALSE); + } - if (NumberOfPagesInitial != NumberOfPages) { - fprintf(stderr, + if (NumberOfPagesInitial != NumberOfPages) { + fprintf(stderr, "InnoDB: AWE: Error: allocated only %lu pages of %lu requested.\n" "InnoDB: Check that you have enough free RAM.\n" "InnoDB: In Windows XP Professional and 2000 Professional\n" @@ -283,18 +281,18 @@ os_awe_allocate_physical_mem( (ulint)NumberOfPages, (ulint)NumberOfPagesInitial); - return(FALSE); - } + return(FALSE); + } fprintf(stderr, "InnoDB: Using Address Windowing Extensions (AWE); allocated %lu MB\n", n_megabytes); - return(TRUE); + return(TRUE); #else UT_NOT_USED(n_megabytes); UT_NOT_USED(page_info); - + return(FALSE); #endif } @@ -324,7 +322,7 @@ os_awe_allocate_virtual_mem_window( } return(os_awe_simulate_window); - + #elif defined(__WIN2000__) byte* ptr; @@ -334,7 +332,7 @@ os_awe_allocate_virtual_mem_window( return(NULL); } - + ptr = VirtualAlloc(NULL, (SIZE_T)size, MEM_RESERVE | MEM_PHYSICAL, PAGE_READWRITE); if (ptr == NULL) { @@ -353,7 +351,7 @@ os_awe_allocate_virtual_mem_window( return(ptr); #else UT_NOT_USED(size); - + return(NULL); #endif } @@ -393,7 +391,7 @@ os_awe_map_physical_mem_to_window( ut_a(ptr < os_awe_simulate_window + os_awe_simulate_window_size); ut_a(page_info >= os_awe_simulate_page_info); ut_a(page_info < os_awe_simulate_page_info + - (os_awe_simulate_mem_size / 4096)); + (os_awe_simulate_mem_size / 4096)); /* First look if some other 'physical pages' are mapped at ptr, and copy them back to where they were if yes */ @@ -401,7 +399,7 @@ os_awe_map_physical_mem_to_window( map = os_awe_simulate_map + ((ulint)(ptr - os_awe_simulate_window)) / 4096; page = ptr; - + for (i = 0; i < n_mem_pages; i++) { if (*map != NULL) { ut_memcpy(*map, page, 4096); @@ -432,13 +430,13 @@ os_awe_map_physical_mem_to_window( } return(TRUE); - + #elif defined(__WIN2000__) BOOL bResult; os_awe_t n_pages; n_pages = (os_awe_t)n_mem_pages; - + if (!(ptr >= os_awe_window)) { fprintf(stderr, "InnoDB: AWE: Error: trying to map to address %lx but AWE window start %lx\n", @@ -487,7 +485,7 @@ os_awe_map_physical_mem_to_window( return(FALSE); #endif -} +} /******************************************************************** Converts the current process id to a number. It is not guaranteed that the @@ -518,7 +516,7 @@ os_mem_alloc_nocache( #ifdef __WIN__ void* ptr; - ptr = VirtualAlloc(NULL, n, MEM_COMMIT, + ptr = VirtualAlloc(NULL, n, MEM_COMMIT, PAGE_READWRITE | PAGE_NOCACHE); ut_a(ptr); @@ -533,60 +531,60 @@ Allocates large pages memory. */ void* os_mem_alloc_large( -/*=================*/ - /* out: allocated memory */ - ulint n, /* in: number of bytes */ - ibool set_to_zero, /* in: TRUE if allocated memory should be set - to zero if UNIV_SET_MEM_TO_ZERO is defined */ - ibool assert_on_error) /* in: if TRUE, we crash mysqld if the memory - cannot be allocated */ +/*===============*/ + /* out: allocated memory */ + ulint n, /* in: number of bytes */ + ibool set_to_zero, /* in: TRUE if allocated memory + should be set to zero if + UNIV_SET_MEM_TO_ZERO is defined */ + ibool assert_on_error)/* in: if TRUE, we crash mysqld if + the memory cannot be allocated */ { #ifdef HAVE_LARGE_PAGES ulint size; int shmid; void *ptr = NULL; struct shmid_ds buf; - + if (!os_use_large_pages || !os_large_page_size) { - goto skip; + goto skip; } #ifdef UNIV_LINUX /* Align block size to os_large_page_size */ size = ((n - 1) & ~(os_large_page_size - 1)) + os_large_page_size; - + shmid = shmget(IPC_PRIVATE, (size_t)size, SHM_HUGETLB | SHM_R | SHM_W); if (shmid < 0) { - fprintf(stderr, "InnoDB: HugeTLB: Warning: Failed to allocate %lu bytes. " - "errno %d\n", n, errno); + fprintf(stderr, "InnoDB: HugeTLB: Warning: Failed to allocate" + " %lu bytes. errno %d\n", n, errno); } else { - ptr = shmat(shmid, NULL, 0); - if (ptr == (void *)-1) { - fprintf(stderr, "InnoDB: HugeTLB: Warning: Failed to attach shared memory " - "segment, errno %d\n", errno); - } - /* - Remove the shared memory segment so that it will be automatically freed - after memory is detached or process exits - */ - shmctl(shmid, IPC_RMID, &buf); + ptr = shmat(shmid, NULL, 0); + if (ptr == (void *)-1) { + fprintf(stderr, "InnoDB: HugeTLB: Warning: Failed to" + " attach shared memory segment, errno %d\n", errno); + } + + /* Remove the shared memory segment so that it will be + automatically freed after memory is detached or process exits */ + shmctl(shmid, IPC_RMID, &buf); } #endif - + if (ptr) { - if (set_to_zero) { + if (set_to_zero) { #ifdef UNIV_SET_MEM_TO_ZERO - memset(ptr, '\0', size); + memset(ptr, '\0', size); #endif - } + } - return(ptr); + return(ptr); } fprintf(stderr, "InnoDB HugeTLB: Warning: Using conventional memory pool\n"); skip: #endif /* HAVE_LARGE_PAGES */ - + return(ut_malloc_low(n, set_to_zero, assert_on_error)); } @@ -595,16 +593,16 @@ Frees large pages memory. */ void os_mem_free_large( -/*=================*/ +/*==============*/ void *ptr) /* in: number of bytes */ { #ifdef HAVE_LARGE_PAGES if (os_use_large_pages && os_large_page_size #ifdef UNIV_LINUX - && !shmdt(ptr) + && !shmdt(ptr) #endif - ) { - return; + ) { + return; } #endif @@ -630,7 +628,9 @@ os_process_set_priority_boost( no_boost = TRUE; } - ut_a(TRUE == 1); +#if TRUE != 1 +# error "TRUE != 1" +#endif /* Does not do anything currently! SetProcessPriorityBoost(GetCurrentProcess(), no_boost); diff --git a/storage/innobase/os/os0sync.c b/storage/innobase/os/os0sync.c index 487e8f40a39..706c10ac613 100644 --- a/storage/innobase/os/os0sync.c +++ b/storage/innobase/os/os0sync.c @@ -20,7 +20,7 @@ Created 9/6/1995 Heikki Tuuri #include "srv0start.h" /* Type definition for an operating system mutex struct */ -struct os_mutex_struct{ +struct os_mutex_struct{ void* handle; /* OS handle to mutex */ ulint count; /* we use this counter to check that the same thread does not @@ -80,24 +80,24 @@ os_sync_free(void) while (event) { - os_event_free(event); + os_event_free(event); - event = UT_LIST_GET_FIRST(os_event_list); + event = UT_LIST_GET_FIRST(os_event_list); } mutex = UT_LIST_GET_FIRST(os_mutex_list); while (mutex) { - if (mutex == os_sync_mutex) { - /* Set the flag to FALSE so that we do not try to - reserve os_sync_mutex any more in remaining freeing - operations in shutdown */ - os_sync_mutex_inited = FALSE; - } + if (mutex == os_sync_mutex) { + /* Set the flag to FALSE so that we do not try to + reserve os_sync_mutex any more in remaining freeing + operations in shutdown */ + os_sync_mutex_inited = FALSE; + } - os_mutex_free(mutex); + os_mutex_free(mutex); - mutex = UT_LIST_GET_FIRST(os_mutex_list); + mutex = UT_LIST_GET_FIRST(os_mutex_list); } } @@ -114,7 +114,7 @@ os_event_create( the event is created without a name */ { #ifdef __WIN__ - os_event_t event; + os_event_t event; event = ut_malloc(sizeof(struct os_event_struct)); @@ -123,7 +123,7 @@ os_event_create( FALSE, /* Initial state nonsignaled */ (LPCTSTR) name); if (!event->handle) { - fprintf(stderr, + fprintf(stderr, "InnoDB: Could not create a Windows event semaphore; Windows error %lu\n", (ulong) GetLastError()); } @@ -146,7 +146,7 @@ os_event_create( event->signal_count = 0; #endif /* __WIN__ */ - /* Put to the list of events */ + /* Put to the list of events */ os_mutex_enter(os_sync_mutex); UT_LIST_ADD_FIRST(os_event_list, os_event_list, event); @@ -170,7 +170,7 @@ os_event_create_auto( const char* name) /* in: the name of the event, if NULL the event is created without a name */ { - os_event_t event; + os_event_t event; event = ut_malloc(sizeof(struct os_event_struct)); @@ -180,12 +180,12 @@ os_event_create_auto( (LPCTSTR) name); if (!event->handle) { - fprintf(stderr, + fprintf(stderr, "InnoDB: Could not create a Windows auto event semaphore; Windows error %lu\n", (ulong) GetLastError()); } - /* Put to the list of events */ + /* Put to the list of events */ os_mutex_enter(os_sync_mutex); UT_LIST_ADD_FIRST(os_event_list, os_event_list, event); @@ -207,7 +207,7 @@ os_event_set( /*=========*/ os_event_t event) /* in: event to set */ { -#ifdef __WIN__ +#ifdef __WIN__ ut_a(event); ut_a(SetEvent(event->handle)); #else @@ -224,7 +224,7 @@ os_event_set( } os_fast_mutex_unlock(&(event->os_mutex)); -#endif +#endif } /************************************************************** @@ -262,7 +262,7 @@ void os_event_free( /*==========*/ os_event_t event) /* in: event to free */ - + { #ifdef __WIN__ ut_a(event); @@ -274,7 +274,7 @@ os_event_free( os_fast_mutex_free(&(event->os_mutex)); ut_a(0 == pthread_cond_destroy(&(event->cond_var))); #endif - /* Remove from the list of events */ + /* Remove from the list of events */ os_mutex_enter(os_sync_mutex); @@ -309,7 +309,7 @@ os_event_wait( ut_a(err == WAIT_OBJECT_0); if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { - os_thread_exit(NULL); + os_thread_exit(NULL); } #else ib_longlong old_signal_count; @@ -317,28 +317,28 @@ os_event_wait( os_fast_mutex_lock(&(event->os_mutex)); old_signal_count = event->signal_count; -loop: - if (event->is_set == TRUE - || event->signal_count != old_signal_count) { - os_fast_mutex_unlock(&(event->os_mutex)); + for (;;) { + if (event->is_set == TRUE + || event->signal_count != old_signal_count) { - if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { + os_fast_mutex_unlock(&(event->os_mutex)); - os_thread_exit(NULL); - } - /* Ok, we may return */ + if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { - return; - } + os_thread_exit(NULL); + } + /* Ok, we may return */ - pthread_cond_wait(&(event->cond_var), &(event->os_mutex)); + return; + } - /* Solaris manual said that spurious wakeups may occur: we have to - check if the event really has been signaled after we came here to - wait */ + pthread_cond_wait(&(event->cond_var), &(event->os_mutex)); - goto loop; + /* Solaris manual said that spurious wakeups may occur: we + have to check if the event really has been signaled after + we came here to wait */ + } #endif } @@ -365,7 +365,7 @@ os_event_wait_time( } else { err = WaitForSingleObject(event->handle, INFINITE); } - + if (err == WAIT_OBJECT_0) { return(0); @@ -378,7 +378,7 @@ os_event_wait_time( } #else UT_NOT_USED(time); - + /* In Posix this is just an ordinary, infinite wait */ os_event_wait(event); @@ -416,7 +416,7 @@ os_event_wait_multiple( ut_a(index < WAIT_OBJECT_0 + n); if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { - os_thread_exit(NULL); + os_thread_exit(NULL); } return(index - WAIT_OBJECT_0); @@ -447,11 +447,11 @@ os_mutex_create( os_mutex_t mutex_str; UT_NOT_USED(name); - + mutex = ut_malloc(sizeof(os_fast_mutex_t)); os_fast_mutex_init(mutex); -#endif +#endif mutex_str = ut_malloc(sizeof(os_mutex_str_t)); mutex_str->handle = mutex; @@ -459,7 +459,7 @@ os_mutex_create( if (os_sync_mutex_inited) { /* When creating os_sync_mutex itself we cannot reserve it */ - os_mutex_enter(os_sync_mutex); + os_mutex_enter(os_sync_mutex); } UT_LIST_ADD_FIRST(os_mutex_list, os_mutex_list, mutex_str); @@ -519,7 +519,7 @@ os_mutex_exit( ut_a(ReleaseMutex(mutex->handle)); #else os_fast_mutex_unlock(mutex->handle); -#endif +#endif } /************************************************************** @@ -537,7 +537,7 @@ os_mutex_free( } UT_LIST_REMOVE(os_mutex_list, os_mutex_list, mutex); - + os_mutex_count--; if (os_sync_mutex_inited) { @@ -565,7 +565,7 @@ os_fast_mutex_init( { #ifdef __WIN__ ut_a(fast_mutex); - + InitializeCriticalSection((LPCRITICAL_SECTION) fast_mutex); #else #if defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10) @@ -584,7 +584,7 @@ os_fast_mutex_init( os_fast_mutex_count++; if (os_sync_mutex_inited) { - os_mutex_exit(os_sync_mutex); + os_mutex_exit(os_sync_mutex); } } @@ -632,7 +632,7 @@ os_fast_mutex_free( DeleteCriticalSection((LPCRITICAL_SECTION) fast_mutex); #else int ret; - + ret = pthread_mutex_destroy(fast_mutex); if (ret != 0) { @@ -642,8 +642,7 @@ os_fast_mutex_free( "InnoDB: pthread_mutex_destroy().\n", (ulint)ret); fprintf(stderr, "InnoDB: Byte contents of the pthread mutex at %p:\n", fast_mutex); - ut_print_buf(stderr, (const byte*)fast_mutex, - sizeof(os_fast_mutex_t)); + ut_print_buf(stderr, fast_mutex, sizeof(os_fast_mutex_t)); fprintf(stderr, "\n"); } #endif diff --git a/storage/innobase/os/os0thread.c b/storage/innobase/os/os0thread.c index c0e66ff2b7e..ff0362840c7 100644 --- a/storage/innobase/os/os0thread.c +++ b/storage/innobase/os/os0thread.c @@ -53,8 +53,8 @@ os_thread_pf( os_thread_id_t a) { #ifdef UNIV_HPUX10 - /* In HP-UX-10.20 a pthread_t is a struct of 3 fields: field1, field2, - field3. We do not know if field1 determines the thread uniquely. */ + /* In HP-UX-10.20 a pthread_t is a struct of 3 fields: field1, field2, + field3. We do not know if field1 determines the thread uniquely. */ return((ulint)(a.field1)); #else @@ -115,11 +115,11 @@ os_thread_create( if (srv_set_thread_priorities) { - /* Set created thread priority the same as a normal query - in MYSQL: we try to prevent starvation of threads by - assigning same priority QUERY_PRIOR to all */ + /* Set created thread priority the same as a normal query + in MYSQL: we try to prevent starvation of threads by + assigning same priority QUERY_PRIOR to all */ - ut_a(SetThreadPriority(thread, srv_query_thread_priority)); + ut_a(SetThreadPriority(thread, srv_query_thread_priority)); } *thread_id = win_thread_id; @@ -128,12 +128,12 @@ os_thread_create( #else int ret; os_thread_t pthread; - pthread_attr_t attr; + pthread_attr_t attr; #if !(defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10)) - pthread_attr_init(&attr); + pthread_attr_init(&attr); #endif - + #ifdef UNIV_AIX /* We must make sure a thread stack is at least 32 kB, otherwise InnoDB might crash; we do not know if the default stack size on @@ -141,28 +141,19 @@ os_thread_create( the size was 96 kB, though. */ ret = pthread_attr_setstacksize(&attr, - (size_t)(PTHREAD_STACK_MIN + 32 * 1024)); - if (ret) { - fprintf(stderr, - "InnoDB: Error: pthread_attr_setstacksize returned %d\n", ret); + (size_t)(PTHREAD_STACK_MIN + 32 * 1024)); + if (ret) { + fprintf(stderr, + "InnoDB: Error: pthread_attr_setstacksize returned %d\n", ret); exit(1); } #endif #ifdef __NETWARE__ ret = pthread_attr_setstacksize(&attr, (size_t) NW_THD_STACKSIZE); - if (ret) { - fprintf(stderr, - "InnoDB: Error: pthread_attr_setstacksize returned %d\n", ret); - exit(1); - } -#endif -#ifdef __NETWARE__ - ret = pthread_attr_setstacksize(&attr, - (size_t)NW_THD_STACKSIZE); - if (ret) { - fprintf(stderr, - "InnoDB: Error: pthread_attr_setstacksize returned %d\n", ret); + if (ret) { + fprintf(stderr, + "InnoDB: Error: pthread_attr_setstacksize returned %d\n", ret); exit(1); } #endif @@ -175,9 +166,9 @@ os_thread_create( #else ret = pthread_create(&pthread, &attr, start_f, arg); #endif - if (ret) { - fprintf(stderr, - "InnoDB: Error: pthread_create returned %d\n", ret); + if (ret) { + fprintf(stderr, + "InnoDB: Error: pthread_create returned %d\n", ret); exit(1); } @@ -185,8 +176,8 @@ os_thread_create( pthread_attr_destroy(&attr); #endif if (srv_set_thread_priorities) { - - my_pthread_setprio(pthread, srv_query_thread_priority); + + my_pthread_setprio(pthread, srv_query_thread_priority); } *thread_id = pthread; @@ -206,14 +197,14 @@ os_thread_exit( { #ifdef UNIV_DEBUG_THREAD_CREATION fprintf(stderr, "Thread exits, id %lu\n", - os_thread_pf(os_thread_get_curr_id())); + os_thread_pf(os_thread_get_curr_id())); #endif os_mutex_enter(os_sync_mutex); os_thread_count--; os_mutex_exit(os_sync_mutex); #ifdef __WIN__ - ExitThread((DWORD)exit_value); + ExitThread((DWORD)exit_value); #else pthread_exit(exit_value); #endif @@ -222,7 +213,7 @@ os_thread_exit( #ifdef HAVE_PTHREAD_JOIN int os_thread_join( -/*=============*/ +/*===========*/ os_thread_id_t thread_id) /* in: id of the thread to join */ { return pthread_join(thread_id, NULL); @@ -241,7 +232,7 @@ os_thread_get_curr(void) return(pthread_self()); #endif } - + /********************************************************************* Advises the os to give up remainder of the thread's time slice. */ @@ -252,13 +243,13 @@ os_thread_yield(void) #if defined(__WIN__) Sleep(0); #elif (defined(HAVE_SCHED_YIELD) && defined(HAVE_SCHED_H)) - sched_yield(); + sched_yield(); #elif defined(HAVE_PTHREAD_YIELD_ZERO_ARG) pthread_yield(); #elif defined(HAVE_PTHREAD_YIELD_ONE_ARG) pthread_yield(0); #else - os_thread_sleep(0); + os_thread_sleep(0); #endif } @@ -279,7 +270,7 @@ os_thread_sleep( t.tv_sec = tm / 1000000; t.tv_usec = tm % 1000000; - + select(0, NULL, NULL, NULL, &t); #endif } @@ -320,8 +311,8 @@ ulint os_thread_get_priority( /*===================*/ /* out: priority */ - os_thread_t handle __attribute__((unused))) - /* in: OS handle to the thread */ + os_thread_t handle __attribute__((unused))) + /* in: OS handle to the thread */ { #ifdef __WIN__ int os_pri; |